Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Given the following code: CountingSort(A, B, k){ Let C[0k] be a new array for i = 0 to k C[i] = 0 for j =
Given the following code:
CountingSort(A, B, k){
Let C[0k] be a new array
for i = 0 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]]] = A[j]
C[A[j]] = C[A[j]] - 1
a. Run CountingSort(A,B, 6) on the array A = {6, 0, 2, 0, 1, 3, 4, 6, 1, 3, 2}. Show the contents of array C and B.
b. What is the smallest possible depth of a leaf in a decision tree for a comparison sort?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started