Question: CountingSort ( A , B , k ) { Let C [ 0 dotsK ] be a new array for i = O to k

CountingSort(A, B, k){
Let C[0dotsK] be a new array
for i=O to k
C[i]=0
for j=1 to A.length
,C[A[j]]=C[A[j]]+1
for i=1 to k
C[i]=C[i]+C[i-1];
, for j= A.length downto 1
B[C[A[j]J]]=A[j]
C[A[j]]=C[A[j]]-1
If we were to change line 8 to "for j=1 to A.length", would counting-sort still sort an array?
True
False
CountingSort ( A , B , k ) { Let C [ 0 dotsK ] be

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!