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

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!