CS 14 - Radix Sort


CS 14 Homepage
Implement Radix Sort, an O(n) sorting algorithm. The algorithm is covered in the text starting on page 471.

Details

Your program should read in a series of whitespace-separated integers from standard input until EOF is reached, sort them using Radix Sort, and output the sorted list, one element per line. No other output should be generated.

For this assignment you may use STL. You cannot make any assumptions about the maximum number of elements that will be read in.

Your program does not need to deal with negative inputs.

Hints

Write a function that given an integer n and a digit d, returns the dth digit of n. You will also need a linked-list implementation of ADT List.

A single linked list is only one "bucket." You'll need 10 buckets. An array or vector is appropriate.

For testing it is probably best if you generate several series of random integers of different sizes. Remember to test that your program works with duplicate values.

© 2003 UC Riverside Department of Computer Science & Engineering. All rights reserved.