Question
Combined Algorithm Consider a modification to merge sort in which n/k sublists of length k are sorted using insertion sort and then merged using the
Combined Algorithm 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.
Required Work
1. Show that insertion sort can sort the n/k sublists, each of length k, in (nk) worst- case time.
2. Show how to merge the sublists in (n lg(n/k)) worst-case time. Hint: merging the n/k sublists will be done by stages. In every stage we merge two sublists by two until we arrive to the final stage with 2 sublists of size n/2 each. Think about how many stages are there and how many numbers need to be merged at every single stage. 3. 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, if we suppose that (nk +n lg(n/k)) can be approximated by either (nk) or (n lg(n/k))?
How should we choose k in practice?
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