Consider an unordered list of N distinct integers. What is the minimum number of element comparisons required to find an integer in the list that is NOT the largest in the list?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2025 Set 2 · Q20
Time
Select one answerSingle correct
Solution
Official answer: A) 1
SearchingTo find an integer that is guaranteed not to be the largest in a list of distinct integers ():
Select any two arbitrary elements from the list, say and .
Perform a single comparison between and .
Whichever element is smaller cannot be the largest element in the list, because there is at least one element ( or ) strictly greater than it.
Thus, only 1 comparison is required.
Hence, the correct option is (A).
Try the question first, then check your work.
Examiner trap
Compare any two arbitrary elements in the list. What can you immediately conclude about the smaller element?
This Searching previous year question is Q20 of the GATE CSE 2025 Set 2 paper. Find more GATE CSE PYQs on Searching 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 1 related Searching 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.
GATE CSE 2025 Set 2 Q20 is the only Searching question in the GATE CSE papers so far.
How GATE tests SearchingIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.