You have an array of n elements. Suppose you implement quicksort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the worst case performance is
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2014 Set 3 · Q14
Time
Select one answerSingle correct
Solution
Official answer: A) O(n2)
Searching, Sorting and HashingIn Quicksort, choosing any fixed position (first element, last element, or the middle/central element) as the pivot does not prevent the worst-case scenario from occurring.
There exist input permutations (such as certain adversarial or already partitioned sequences) where the central element chosen as the pivot is consistently the smallest or largest element in the current subarray, resulting in an unbalanced partition of sizes and .
The recurrence relation in the worst case is:
Solving this recurrence yields:
Hence, the tightest upper bound for the worst-case performance is .
Try the question first, then check your work.
Examiner trap
Choosing a fixed-index pivot (even the middle element) does not guarantee balanced partitions for all input permutations.
This Searching, Sorting and Hashing previous year question is Q14 of the GATE CSE 2014 Set 3 paper. Find more GATE CSE PYQs on Searching, Sorting and Hashing in Algorithms, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Searching, Sorting and Hashing PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Searching, Sorting and Hashing has 27 GATE CSE PYQs across 20 papers from 2012 to 2026. 9 of them are 1-mark MCQs like this one, and GATE CSE 2014 Set 3 has 3.
How GATE tests Searching, Sorting and HashingIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.