Question: 8. [10] You are given an unsorted array A of size n. We wish to output the k smallest elements in A in sorted order.

 8. [10] You are given an unsorted array A of size

8. [10] You are given an unsorted array A of size n. We wish to output the k smallest elements in A in sorted order. Determine the asymptotic worst-case complexities of the following approaches in terms of n and k. (In all cases, simplify complexities to eliminate lower order terms and constants.): (a) Sort A in increasing order using Mergesort. Output the first k elements (2 pts). (b) Scan A for the smallest element; output and delete it when found. Do this k times (2 pts). (c) Use Build Heap to convert A into a min-heap. Call Extract_Min k times (2 pts). Which approach would you choose to implement and why when k = n/2 (2 pts)? Which approach would you choose to implement and why when k = 2 (2 pts]

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!