Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

=+5 How does HRM relate to efforts to increase innovation?

Answered: 1 week ago