GATE CSE 2019 Q30: Quicksort on 25 distinct elements: probability pivot lands in worst location
- Algorithms
- 1 mark
- NAT
- No negative marking
Syllabus topic: Searching, sorting and hashing
Question
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 ________.
Try it: numerical answer: type the value
Show answer and explanation
Answer: 0.08 (official GATE 2019 final answer key)
Concept used: Quicksort's worst split happens when the pivot is the smallest or largest element, leaving one empty side.
First step: Identify which pivot choices put it at an end of the array, and divide that count by the 25 equally likely choices.
Full step-by-step solution
Loading…
Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.
More questions on Searching, sorting and hashing
Every PYQ on this topic →Share this question
Source: official GATE 2019 CS question paper and final answer key, organised by IIT Madras. Question paper · Answer key
More Algorithms PYQs
- 2026 Session 1 · Q17Solve nested recurrences T1 = 4T1(n/2) + T2, T2 = 5T2(n/4) + log n
- 2026 Session 1 · Q41Shortest paths with at most k edges: two statements
- 2026 Session 1 · Q47Condition forcing a vertex into every minimum vertex cover
- 2026 Session 1 · Q49Cycle and cut properties of MSTs with distinct weights
- 2026 Session 1 · Q50Impossible DFS discovery/finish orderings for a DAG edge
- 2026 Session 1 · Q55Properties of 2-colorable (bipartite) graphs