next up previous
Next: Pseudocode Up: CSE 2320: Algorithms and Previous: Counting Sort

Example

Let array A be the following array (n=8, k=7).

\(1 \ldots n\)
5 7 3 5 2 1 4 3



Compute C[j] as the number of elements in A[] $\leq$ j. Array C is thus the following array.



\(1 \ldots k\)
1 2 4 5 7 7 8
0 1 3 4 6   7
    2   5    

Array B contains the final sorted array.



1 2 3 3 4 5 5 7



Copyright © 1998 The University of Texas at Arlington