Answered step by step
Verified Expert Solution
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started