GateAI
Searching, Sorting and Hashing

GATE CSE 2014 Set 3 · Q14

MCQ1 markEasy

Time

You have an array of nn 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

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) O(n2)

Searching, Sorting and Hashing

In 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 00 and n−1n-1.

The recurrence relation in the worst case is:

T(n)=T(n−1)+O(n)T(n) = T(n-1) + O(n)

Solving this recurrence yields:

T(n)=O(n2)T(n) = O(n^2)

Hence, the tightest upper bound for the worst-case performance is O(n2)O(n^2).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

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

Where do you stand for GATE?

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.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Searching, Sorting and Hashing in GATE CSE

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 Hashing

More from GATE CSE 2014 Set 3

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2014 Set 3 · Q14 · MCQ

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

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.