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 sublists of length are sorted using
insertion sort and then merged using the standard merging mechanism ie you only do
insertion sort at one level of recursion tree where is a value to be determined.
a Show that the insertion sort can sort the sublists each of length in worstcase
time.
b Show that the sublists can be merged in worstcase time. Hint: Assume
that at the level of the recursion tree where we start merging, we have sublists. How
many levels are there above the level we start merging if that level has sublists ie sub
arrays and what is the cost of merging in each of these levels?
c Given that the modified algorithm runs in worstcase time, what is the
largest value of as a function of and in notation for which the modified algorithm has
the same running time as merge sort in notation? Hint: Which value of makes
: Show that works.
d How should we choose in practice? Hint: consider the list ie 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 as the largest list length on which insertion sort is faster than merge
sort?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
