Counting sort (assuming the input key values are integers in the range 0 to m - 1)

Question:

Counting sort (assuming the input key values are integers in the range 0 to m - 1) works by counting the number of records with each key value in the first pass, and then uses this information to place the records in order in a second pass. Write an implementation of counting sort (see the implementation of radix sort for some ideas). What can we say about the relative values of m and n for this to be effective? If m < n, what is the running time of this algorithm?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: