Question: In this assignment you are asked to implement Counting Sort. This algorithm takes as input an array of n integers in the range of 0
In this assignment you are asked to implement Counting Sort. This algorithm takes as input
an array of integers in the range of to Its running time is and hence is more
efficient than all algorithms seen in class. In contrast to those seen in class, Counting Sort
does not use comparisons.
The signature of the main class should be public class countingSort and is supposed to
contain the following method:
public static void sortint A
Next we present the pseudocode for countingSORT A B k taken from A is the array
to be sorted and has length Also, its elements are integers in the range B is an
array that will hold the sorted output. is an auxiliary array for temporary
storage. You should use this as the basis for your Java implementation. Once you have
implemented it include some test cases.
Here is an example of a run. The array to be sorted is A whose size is
The integers in A are in the range to Here is a trace:
At line :
At line :
Iteration of loop in line :
Iteration of loop in line :
Iteration of loop in line :
After all iterations of loop in line :
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
