Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Given an unsorted array A of n distinct integers and an integer k , you need to return the k smallest integers In the array
Given an unsorted array A of n distinct integers and an integer k you need to return the k smallest integers In the array in sorted order, where k may be any infeger between and n Suppose that you have the following three algorithms to solve this problem.
A: Sort the array in increasing order, then list the first k integers after sorting.
A: Build a minheap from these n integers, then call ExtractMin k times.
A: Use the linear time selection algorithm to find the kth smallest integer in the array, then partition the array about that number to obtain the k smallest numbers in the array, and finally sort the k smallest numbers.
Assume that you are using mergesort as your sorting algorithm, and use the linear time build heap algorithm to build the heap.Let Tn k denote the worstcase running time of Algorithm ALet Tn k denote the worstcase running time of Algorithm ALet Tn k denote the worstcase running time of Algorithm AAnalyze the worstcase running times of the algorithms.
What is the asymptotic notation of Tn K Justify your answer.
What is the asymptotic notation of Tn K Justify your answer.
What is the asymptotic notation of Tn K Justify your answer.
Assume that worstcase time complexity is the only metric in choosing algorithms. Among the three algorithms, which algorithm would you choose to solve this problem? Justify why.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started