Problem 2-1 Insertion sort on small arrays in merge sort Although merge sort runs in e(n lg n) worst-case time and inser

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Problem 2-1 Insertion sort on small arrays in merge sort Although merge sort runs in e(n lg n) worst-case time and inser

Post by answerhappygod »

Problem 2 1 Insertion Sort On Small Arrays In Merge Sort Although Merge Sort Runs In E N Lg N Worst Case Time And Inser 1
Problem 2 1 Insertion Sort On Small Arrays In Merge Sort Although Merge Sort Runs In E N Lg N Worst Case Time And Inser 1 (44.37 KiB) Viewed 9 times
Problem 2-1 Insertion sort on small arrays in merge sort Although merge sort runs in e(n lg n) worst-case time and insertion sort runs in (n²) worst-case time, the constant factors in insertion sort can make it faster in practice for small problem sizes on many machines. Thus, it makes sense to coarsen the leaves of the recursion by using insertion sort when subproblems become sufficiently small. 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. a. Show that insertion sort can sort the n/k sublists, each of length k, in e(nk) worst-case time. b. Show how to merge the sublists in O(n Ig (n/k)) worst-case time. c. Given that the modified algorithm runs in O(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, in terms of e- notation? d. How should we choose k in practice?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply