The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is …
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2014 Set 1 · Q39
Time
Your answerNumerical answer
Solution
Official answer: 148
Searching, Sorting and HashingTo find both the minimum and the maximum of numbers simultaneously using the optimal pairwise comparison method:
If is even, compare the first two elements to initialize the current minimum and maximum (requires comparison).
For the remaining elements, process them in pairs:
Compare the two elements in the pair ( comparison).
Compare the smaller element with the current minimum ( comparison).
Compare the larger element with the current maximum ( comparison).
This takes comparisons for every pair, giving comparisons.
Total comparisons formula for even :
Substituting :
Thus, the minimum number of comparisons is 148.
Try the question first, then check your work.
Examiner trap
Process elements in pairs: compare the two elements first, then compare the smaller with min and the larger with max.
This Searching, Sorting and Hashing previous year question is Q39 of the GATE CSE 2014 Set 1 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. 4 of them are 2-mark NAT questions like this one, and GATE CSE 2014 Set 1 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.