Question: 3 Divide&Conquer, Complexity Analysis ( 1 0 p ) Consider the task of finding the smallest k entries in an array of length n .

3 Divide&Conquer, Complexity Analysis (10p)
Consider the task of finding the smallest k entries in an array of length n. We could solve this in O(nlogn)
by first sorting the array (e.g., via MergeSort), and then returning the first k entries. This can be made
faster via the following modification of MergeSort. Here, after the merge operation, only the first k entries
are returned. This is faster than regular MergeSort, because we never need to merge arrays of length >k.
But what is the precise complexity?
Algorithm 1: Modified MergeSort.
procedure SMALLEST(A,k)
if length of Ak then
return MERGESORT (A)
else
left =SmaLLESTA[1,dots,n2],k?? the smallest k entries of the left half
right =SmallestA[n2+1,dots,n],k?? the smallest k entries of the right half
merged left, right
 3 Divide&Conquer, Complexity Analysis (10p) Consider the task of finding the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To understand the time complexity of the modified MergeSort algorithm given we need to analyze it by ... View full answer

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!