Recent questions tagged countingsort

1.7k
views
2 answers
0 votes
Describe an algorithm that, given $n$ integers in the range $0$ to $k$ preprocesses its input and then answers any query about how many of the $n$ integers fall ... in $O(1)$ time.Your algorithm should use $\Theta(n+k)$ preprocessing time.
383
views
0 answers
0 votes
Suppose that we were to rewrite the for loop header in line $10$ of the COUNTINGSORT as 10 for j = 1 to A.lengthShow that the algorithm still works properly. Is the modified algorithm stable?
404
views
1 answers
0 votes
375
views
0 answers
0 votes
COUNTING-SORT(A, B, k) 1 let C[0, ,k] be a new array 2 for i = 0 to k 3 C[i] = 0 4 for j = 1 to A.length 5 C[A[j]] = C[A[j]] + 1 6 // C ... - 1illustrate the operation of COUNTING-SORT on the array $A=\langle 6,0,2,0,1,3,4,6,1,3,2 \rangle $
To see more, click for the full list of questions or popular tags.