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


Radix sort (Pascal version available)


list sort( r ) list r; { list head[M], tail[M]; int i, j, h; for (i=D; i>0; i--) { for (j=0; j<M; j++) head[j] = NULL; while ( r != NULL ) { h = charac( i, r->k ); if ( head[h]==NULL ) head[h] = r; else tail[h]->next = r; tail[h] = r; r = r->next; }; /*** Concatenate lists ***/ r = NULL; for (j=M-1; j>=0; j--) if ( head[j] != NULL ) { tail[j]->next = r; r = head[j]; } }; return( r ); };

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



© Addison-Wesley Publishing Co. Inc.