CMPSCI 311: Theory of Algorithms

David Mix Barrington

Fall, 2003

Discussion Solutions #8

from Wednesday 5 Nov 2003

Counting and Radix Sorts

Questions are in black, answers in blue.

Here we will use the main idea of Levitin 7.1 to implement a radix sort of strings.


     public class StringArray
        int n; // length of array
        int k; // length of each string
        String [] a; // the array of n strings, each must be of length k

     public void sortBy (int i)
     {// does stable sort on array a by the i'th letter of the strings

     public void sort()
     {// sorts strings in a lexicographically

Last modified 5 November 2003