Question: 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?
 Consider a modification to merge sort in which nk sublists of

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!