Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7. (5 points) Although merge sort runs in n lg n) worst-case time and insertion sort runs in O(n^2) worst-case time, the constant factors in

image text in transcribed

7. (5 points) Although merge sort runs in n lg n) worst-case time and insertion sort runs in O(n^2) worst-case time, the constant factors in insertion sort make it faster for small n. Thus, it makes sense to use insertion sort within merge 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. 7a) Show that the n/k sublists, each of length k, can be sorted by insertion sort in (nk) worst-case time. 7b) Show that the sublists can be merged in (n lg (n/k) worst-case time. 7c) Given that the modified algorithm runs in (nk + n lg (n/k)) worst-case time, what is the largest asymptotic (O notation) value of k as a function of n for which the modified algorithm has the same asymptotic running time as standard merge sort? 7d) How should k be chosen in practice

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions