Question: COUNTing - SORT ( A , B , n , k ) let C [ 0 dotsk ] be a new array for i =

COUNTing-SORT(A,B,n,k)
let C[0dotsk] be a new array
for i=0 to k
C[i]=0
for j=1 to n
j=1ton
C[A[j]]=C[A[j])+1
for i=1 to k
C[i]=C[i]+C[i-1]
for ?bar(j)=n downto 1
If you run COUNTING-SORT in the array below:
\table[[4,2,0,1,2,4,1,1,2]]
What is the result of Array C after point A (2nd for loop) is over?
COUNTing - SORT ( A , B , n , k ) let C [ 0 dotsk

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 Programming Questions!