Question

Consider an unordered list of NN 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?

Choose one option
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 NN integers are distinct (assuming N≥2N \ge 2), take any two elements aa and bb from the list and perform 11 comparison:

  • If a<ba < b, then aa is strictly smaller than bb, so aa cannot be the largest element in the list.
  • If b<ab < a, then bb cannot be the largest element in the list.

Thus, 11 comparison always suffices.

Final answer

Option (A)

Common trap

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.