GateAI
Searching, Sorting and Hashing

GATE CSE 2019 · Q20

NAT1 markEasy

Time

An array of 25 distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at random. The probability that the pivot element gets placed in the worst possible location in the first round of partitioning (rounded off to 2 decimal places) is _______.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 0.08 (±0)

Searching, Sorting and Hashing

In quicksort partitioning of an array of nn distinct elements, the worst possible partitioning occurs when the pivot element is either the minimum or the maximum element of the array (resulting in an unbalanced subproblem split of sizes 00 and n−1n-1).

  • Total number of elements, n=25n = 25.

  • Number of worst-case pivot positions = 22 (the smallest element and the largest element).

Since the pivot is chosen uniformly at random, the probability is:

P=225=0.08P = \frac{2}{25} = 0.08

Thus, the probability rounded off to 2 decimal places is 0.08.

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 Q20 of the GATE CSE 2019 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. 5 of them are 1-mark NAT questions like this one, and it is the only one in GATE CSE 2019.

How GATE tests Searching, Sorting and Hashing

More from GATE CSE 2019

Share this solution

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

GateAI solution cardGATE CSE 2019 · Q20 · NAT

An array of 25 distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at random. The probability that the pivot element gets placed in the worst possible location in the first round of partitioning (rounded off to 2 decimal places) 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.