GATE / CS ARCHIVE

GATE CSE 2025 SET 2 / QUESTION 20

GATE CSE 2025 Set 2 Q20

Algorithms · Searching, Sorting & Selection · Full GATE CSE 2025 Set 2 paper

GATE 2025 Set 2, Q20 1 mark · MCQ
Report issue

Searching, Sorting & Selection

Question 20, GATE 2025: An unordered list contains N distinct integers. In the comparison model, what is the minimum number of element comparisons needed to find any element that is not the largest? Assume N≥2.
Options: A. 1; B. N−1; C. N; D. 2N−1.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Compare any two distinct list elements, say a and b. If a<b, return a; otherwise return b. Because the keys are distinct, the returned key is strictly smaller than the other compared key, which also belongs to the list. This is already a certificate that the returned key is not the maximum of the entire list. We do not need to identify the maximum or inspect the other N−2 elements.

One comparison is sufficient and, in the worst-case comparison model, necessary. With zero comparisons there is no ordering evidence about the chosen element; arbitrary distinct input values could make it the largest. N−1 is the familiar bound for finding the actual maximum, which is a stronger problem. The assumption N≥2 is necessary: for N=1 no nonmaximum element exists. Answer: A.

Original paper, page 18 · Answer key