Skip to content
Official PYQ · 2001

GATE CS 2001 Q1.14 — Searching, Sorting, Hashing

Explain with AI

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?

Choose one option
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 00 and n−1n-1. The recurrence relation for this worst-case scenario is:

T(n)=T(n−1)+Θ(n)T(n) = T(n-1) + \Theta(n)

Solving this recurrence yields T(n)=Θ(n2)T(n) = \Theta(n^2). Thus, the worst-case time complexity of randomized quicksort remains O(n2)O(n^2).

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Searching, Sorting, Hashing questions