Counting methods for sorting

Hide text Hide pseudo-code

Sort the following array of key values by means of counting sort.

Some additional problems.

 1. for (j=0; j<M; j++)
 2.   aux[j] = 0;
 3. for (i=0; i<N; i++) 
 4.   aux[input[i]]++;
 5. for (j=1; j<M; j++)
 6.   aux[j] += aux[j-1];
 7. for (i=N-1; i>=0; i--) { 
 8.   output[aux[input[i]]] = input[i];
 9.   aux[input[i]]--;
10. }


  Created Wed Jun 20 16:00:42 EEST 2007 - Powered by SVG-hut