Question: I have attached the answer below but i don't understand how to get it 7) Counting sort processes an array a of integers by counting

 I have attached the answer below but i don't understand how

I have attached the answer below but i don't understand how to get it

to get it 7) "Counting sort" processes an array a of integers

7) "Counting sort" processes an array a of integers by counting how many of each number occurs in a, then assigning the elements of a to the result array b using the counts to determine their locations. It is implemented by the static method countingsort. returns a sorted copy of a, assuming that it contains only integers in the range 0 k-1 public static int counting Sort int a, int k) int counts new int [kl for (int x a) counts [x]++; int total 0; for int i 0; i ki i++) int old Count counts [i] counts [i] total total oldCount int result new int [a length] for (int x a) result counts [x] x; counts [x]++; return result; a) Show how the application countingsort (13, 7,1, 3, 8,2, 11, 10) is processed. In particular, show the state of the array counts at the end of the first loop, and at the end of the second loop, and how counts and result change during the third loop. (7 marks) b) Comment on the performance of Countingsort, as formally as you can. (3 marks) For what data will the algorithm be especially fast

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!