Question: COUNTING - SORT ( A , n , k ) let B [ 1 : n ] and C [ 0 : k ] be
COUNTINGSORT
let : and : be new arrays
for to
for to
now contains the number of elements equal to
for to
now contains the number of elements less than or equal to
Copy to starting from the end of
for downto
to handle duplicate values
return
a Following the algorithm above, illustrate the operation of COUNTINGSORT on the array
~~ by assuming Show all intermediate steps, including changes on array B and C
b Does the algorithm perform sorting in place? Justify your answer.
c Is the algorithm stable? Justify your answer.
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
