Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Consider a modification to merge sort in which nk sublists of length k are sorted using
insertion sort and then merged using the standard merging mechanism (i.e. you only do
insertion sort at one level of recursion tree), where k is a value to be determined.
(a) Show that the insertion sort can sort the nk sublists each of length k in (nk) worst-case
time.
(b) Show that the nk sublists can be merged in (nlg(nk)) worst-case time. Hint: Assume
that at the level of the recursion tree where we start merging, we have nk sublists. How
many levels are there above the level we start merging if that level has nk sublists (i.e. sub
arrays) and what is the cost of merging in each of these levels?
(c) Given that the modified algorithm runs in (nk+nlg(nk)) worst-case time, what is the
largest value of k as a function of n and in -notation for which the modified algorithm has
the same running time as merge sort in -notation? Hint: Which value of k makes
{:nlg(nk))=(nlgn)? Show that k=(lgn) works.
(d) How should we choose k in practice? Hint: consider the list (i.e. array) lengths for which
insertion sort is better than merge sort, which is a range of integers to choose from. Then
consider which of these values is the best option to start with when combined with merge
sort. Can we choose k as the largest list length on which insertion sort is faster than merge
sort?
image text in transcribed

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

What is the cycle of intimate partner abuse?

Answered: 1 week ago