Question
Consider an unordered list of 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?
Official answer and solution
- Official answer
- A
- From
- Official GATE 2025 answer key
Solution
Compare any two elements in the list and pick the smaller one.
Since all integers are distinct (assuming ), take any two elements and from the list and perform comparison:
- If , then is strictly smaller than , so cannot be the largest element in the list.
- If , then cannot be the largest element in the list.
Thus, comparison always suffices.
Option (A)
Misreading the question as finding the second-largest or smallest element.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2025 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 20 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.