Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose you are given the task of sorting n = 1000, 32 bit binary keys. You have decided to use radix sort (which uses counting

Suppose you are given the task of sorting n = 1000, 32 bit binary keys. You have decided to use radix sort (which uses counting sort as a stable sorting algorithm subroutine) for this problem but you are unsure whether to use counting sort on each bit separately or whether to use counting sort on groups of bits to minimize the total running time. You want to find out whether it is best to assign 1,4,8 or 16 bits per group and perform to the counting sort on each group. You are provided with a counting sort procedure that sorts n numbers (each numbers taking value in the range {0, . . . , k}) with exact time complexity of 5n + 4k. Find the exact runtime of the following four cases by filling out the following table and justifying your answer

(a) Use 1 bit/per group and call counting sort subroutine for each group.

(b) Use 4 bit/per group and call counting sort subroutine for each group.

(c) Use 8 bit/per group and call counting sort subroutine for each group.

(d) Use 16 bit/per group and call counting sort subroutine for each group.

(e) Which of the above three options is preferable? Explain why


part (a) part (b) part (c) part (d) # possible values #bits/groups# group (d) per group (k) Countingsort time per group Radix sort time i.e., Counting sort time in total (for all groups)

Step by Step Solution

3.49 Rating (146 Votes )

There are 3 Steps involved in it

Step: 1

To determine which option is preferable in terms of runtime well calculate the exact runtime for eac... 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

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Algorithms questions

Question

words or less.

Answered: 1 week ago