Home / Expert Answers / Computer Science / 3-the-following-is-a-modified-version-of-counting-sort-new-lines-or-modifie-pa398

(Solved): 3. The following is a modified version of Counting sort. New lines or modifie ...



3. The following is a modified version of Counting sort. New lines or modified lines of code have the comment //CHANGED clo???????

3. The following is a modified version of Counting sort. New lines or modified lines of code have the comment '//CHANGED' close to them. A: array of integer numbers k: maximum value stored in A k1: minimum value stored in A//CHANGED \begin{tabular}{|r|c|} \hline 1 & \\ 2 & function counting-sort \( (A, k, k 1) \) \\ 3 & \( C=n e w \) array \( (k-k 1+1) \) of zeros //CHANGED \\ 4 & \( R=n e w \) array \( ( \) length \( (A)) \) of zeros \\ 5 & poss= \\ 6 & for \( 0<=i<1 \) length \( (A) \) do \\ 7 & \( C[A[i]-k 1]=C[A[i]-k 1]+1 / / C H A N G E D \) \\ 8 & end for \\ 9 & for \( 0<=i<(k-k 1+1) \quad \) do \( / / C H A N G E D \) \\ 10 & for pos \( \leq r< \) pos \( +C[i] \) do \\ 11 & \( R[r]=i+k 1 / / C H A N G E D \) \\ 12 & end for \\ 13 & pos=r \\ 14 & end for \\ 15 & return \( R \) \\ 16 & end function \end{tabular} What is the content of array \( R \) for the input array \( A= \) \[ [0,-3,-3,1,2] \] after executing this modified version of Counting sort? \[ \begin{array}{c} {[1,2,0]} \\ {[-3,-3,0,1,2]} \\ {[0,2,1,-3,-3]} \end{array} \] Execution error, counting sort does not work with negative numbers none of the others


We have an Answer from Expert

View Expert Answer

Expert Answer


The question is to cho
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe