Question:

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?

Show Hint

When searching for a non-maximum element in an unordered list, a single comparison is sufficient as soon as we find any element smaller than the maximum.
Updated On: Apr 7, 2025
  • \(1\)
  • \(N-1\)
  • \(N\)
  • \(2N-1\)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

To determine a number that is not the largest in an unordered list of \(N\) distinct integers, we only need to compare two elements.
  • If we compare any two distinct elements, at least one of them is guaranteed to be smaller than the maximum.
  • This means that in just one comparison, we can confirm that one of the numbers is not the largest.

Since we only need to confirm that one of the two numbers is smaller than the maximum, the minimum number of comparisons required is 1.

Was this answer helpful?
0
0

Questions Asked in GATE CS exam

View More Questions