Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The objective of this assignment is to reinforce the understanding of Counting Sort. Exercise ( 100 points) Counting Sort COUNTING-SORT (A,B,k) 1 let C[0k] be

image text in transcribed
The objective of this assignment is to reinforce the understanding of Counting Sort. Exercise ( 100 points) Counting Sort COUNTING-SORT (A,B,k) 1 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 // C[i] now contains the number of elements equal to i. for i=1 to k C[i]=C[i]+C[i1] I/ C[i] now contains the number of elements less than or equal to i. for j=A. length downto 1 B[C[A[j]]]=A[j]C[A[j]]=C[A[j]]1 Consider the sequence A={5;5;7;6;9;8;11;6;7;8). (No need to justify results by tracing the algorithm) a) (1 point) What should be k to efficiently and correctly execute Counting-Sort on Sequence A ? b) (11 points) Execute Counting-Sort on Sequence A. We are interested in the for loop Lines 4-5. Provide the array C right after the iteration j=3 is executed. c) (11 points) Execute Counting-Sort on Sequence A. We are interested in the for loop Lines 4.5. Provide the array C right after the iteration j=5 is executed. d) (11 points) Execute Counting-Sort on Sequence A. We are interested in the for loop Lines 4-5. Provide the array C right after the iteration j= A.length- 1 is executed. e) (11 points) Execute Counting-Sort on Sequence A. We are interested in the for loop Lines 7-8. Provide the array C right after the iteration i=3 is executed. f) (11 points) Execute Counting-Sort on Sequence A. We are interested in the for loop Lines 7.8. Provide the array C right after the iteration i=5 is executed. B) (11 points) Execute Counting-Sort on Sequence A. We are interested in the for loop Lines 7.8. Provide the array C right after the iteration i=k1 is executed. h) (11 points) Execute Counting -Sort on Sequence A. We are interested in the for loop lines 10-12. Provide the array C right after the iteration j=6 is executed. i) (11 points) Execute Counting-Sort on Sequence A. We are interested in the for loop lines 10-12. Provide the array C right after the iteration j=5 is executed. j) (11 points) Execute Counting Sort on Sequence A. We are interested in the for loop lines 10-12. Provide the array C right after the iteration j=3 is executed

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions