Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using Randomized quicksort?
View worked solution
Answer: C
In Randomized Quicksort, the pivot element is selected uniformly at random from the subarray. This randomization helps avoid the worst-case behavior on already sorted or nearly sorted inputs in practice.
However, the worst-case complexity is defined as the maximum time taken over any possible sequence of choices. In the absolute worst-case scenario, the random number generator might repeatedly select the minimum (or maximum) element as the pivot at every recursive step.
This results in highly unbalanced partitions of sizes and . The recurrence relation for this worst-case scenario is:
Solving this recurrence yields . Thus, the worst-case time complexity of randomized quicksort remains .
Free practice · Your answers on this page are not saved.
