Problem

You can sort a large array of integers that are in the range 1 to n by using an array coun...

You can sort a large array of integers that are in the range 1 to n by using an array count of n entries to count the number of occurrences of each integer in the array. For example, consider the following array of 14 integers that range from 1 to 9:

9 2 4 8 9 4 3 2 8 1 2 7 2 5

Form an array count of 9 elements such that count[i- 1] contains the number of times that i occurs in the array to be sorted. Thus, count is

1 4 1 2 1 0 1 2 2

We now know that 1 occurs once in the original array, 2 occurs four times, and so on. Thus, the sorted array is

1 2 2 2 2 3 4 4 5 7 8 8 9 9

a. Implement this sorting algorithm.


b. Using Big Oh notation, describe the efficiency of this algorithm.


c. Is this algorithm useful as a general sorting algorithm? Explain.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 8
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT