Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CLRS 2-1: Although merge sort runs in (n lg n) worst-case time and insertion sort runs in (n2) worst-case time, the constant factors in insertion

image text in transcribed

CLRS 2-1: Although merge sort runs in (n lg n) worst-case time and insertion sort runs in (n2) worst-case time, the constant factors in insertion sort can make it faster in practice for small problem sizes on many machines. Thus, it makes sense to coarsen the leaves of the recursion by using insertion sort within merge sort when subproblems become sufficiently small. Consider a modification to merge sort in which n/k sublists of length k are sorted using insertion sort and then merged using the standard merging mechanism, where k is a value to be determined. (a) 15 points show that insertion sort can sort the n/k sublists, each of length k, in (nk) worst-case time (b) 15 points! Show how to merge the sublists in (n lg(n/k)) worst-case time. (c) 15 points Given that the modified algorithm runs in (nk+ n lg(n/k)) worst-case time, what is the largest value of k as a function of n for which the modified algorithm has the same running time as standard merge sort, in terms of -notation? d) I5 pointsl How should we choosek in practice

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

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions

Question

what is objective housing?

Answered: 1 week ago

Question

Write formal proposal requests.

Answered: 1 week ago

Question

Write an effective news release.

Answered: 1 week ago

Question

Identify the different types of proposals.

Answered: 1 week ago