The median of elements can be found in time. Which one of the following is correct about the complexity of quick sort, in which median is selected as pivot?
View worked solution
Answer: B
When the median of elements is selected as the pivot in Quick Sort, the array is always partitioned into two equal (or nearly equal) halves of size approximately .
The recurrence relation for the time complexity is given by:
We are given that the median can be found in time. The partitioning step also takes time. Therefore, the recurrence relation simplifies to:
Applying the Master's Theorem for divide-and-conquer recurrences of the form :
- ,
- Since , we fall into Case 2 of the Master's Theorem.
Thus, the solution to the recurrence is:
Hence, the correct option is B.
Free practice · Your answers on this page are not saved.
