Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise (30 points) Counting Sort COUNTING-SORT(A, B, k) 1 let Co..k] be a new array 2 for i = 0 to k 3 C[i] =

image text in transcribed

Exercise (30 points) Counting Sort COUNTING-SORT(A, B, k) 1 let Co..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[i] now contains the number of elements equal to i. 7 for i = 1 to k 8 C[i] = C[i] + C[i 1] 9 11 C[i] now contains the number of elements less than or equal to i. 10 for j = A.length downto 1 11 B[C[A[j]]] = A[j] 12 C[A[;)] = C[A[j]] - 1 Suppose that we are given a sequence A of n positive real numbers (az, az, .., a.) to sort. a) (2 points) Can you use Count Sort AS IS to sort A? Explain b) (28 points) How can you adapt Counting Sort to sort the sequence A? Clearly state your assumptions and describe clearly using pseudocode your new Counting Sort algorithm

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_2

Step: 3

blur-text-image_3

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

List three examples of BPR used in the expenditures processes.

Answered: 1 week ago

Question

Solve the equation. x + 12/x = 7

Answered: 1 week ago

Question

LO1 Understand risk management and identify its components.

Answered: 1 week ago