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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f38eb72da7b_81466f38eb6a40b4.jpg)
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
Get step-by-step solutions from verified subject matter experts
