template void BucketSort(Vector & a, int n, int radix) // precondition: radix is upper bound on largest element of a // n = # of elements of a // // from Sedgewick, modified as explanation given in Weiss (advanced) // does "bucket sort" { static Vector count(radix,0); // one per program int k,j,index; for(k=0;k> (y)) & ~(~0 << (z)) )) #define WORDSIZE 8 // number of "chunks" at a time #define WORDS_PER_INT 4 #define WORD_VALUES (1 << WORDSIZE) // 2^WORDSIZE template void RadixSort(Vector & a,int n) // precondition: n = # of elements of a // // from Sedgewick, (code in book is incorrect!!) { static Vector count(WORD_VALUES); // once per program int j,k,radix=WORD_VALUES; // see Sedgewick for explanation (yeah, right) for(j=0;j=0;k--){ extra[--count[bits(a[k],j*WORDSIZE,WORDSIZE)]] = a[k]; } for(k=0;k