[Home]
[Contents]
[Chapter]
[Previous Algorithm]
[Next Algorithm]


Heapsort (Pascal version available)


sort( r, lo, up ) ArrayToSort r; int lo, up; {int i; /*** construct heap ***/ for ( i=up/2; i>1; i-- ) siftup(r,i,up); /*** repeatedly extract maximum ***/ for ( i=up; i>1; i-- ) { siftup(r,1,i); exchange( r, 1, i ); } };

C source (415.sort.c) Pascal source (415.sort.p)



© Addison-Wesley Publishing Co. Inc.