Interesting

Bubble sort

    per(i<-0;i<N;i++)
        per(j<-i+1;j<N;j++)
            si(v[i] > v[j])     // si (*(pv+i) > *(pv+j))
                tmp<-v[i];      //      tmp<-*(pv+i)
                v[i]<-v[j];     //      *(pv+i)<-*(pv+j)
                v[j]<-tmp;      //      *(pv+j)<-tmp;
            fsi
        fper
    fper

last updated on April 11, 2015, 7:43 p.m.
Back