435 views
7 votes
7 votes

For quick sort pivot selection you are provided with an buggy implementation of Median select, which can return any element between $(n/3)^{rd}$ smallest and $(2n/3)^{rd}$ smallest in $O(n)$ time. With this function to choose the pivot, which of the following is/are TRUE for the QuickSort implementation? (Mark all CORRECT choices)

  1. In best case it can run in $O(n)$ time
  2. In worst case it will take $\Theta(n^2)$ time
  3. In worst case it will take $\Theta(n \log n)$ time
  4. In best case, it will run in $\Omega(n \log n)$ time

1 Answer

3 votes
3 votes
Worst case complexity of quick sort occurs in 2 cases, when smallest or largest element of array is chosen as pivot element. Now, both the smallest and largest elements of array cannot lie between (n/3)rd smallest element and (2n/3)rd smallest element of array. So both the case of worst cases are avoided and hence worst case can’t be O(n^2).

So answer is C, D
Answer:

Related questions

7 votes
7 votes
2 answers
1