What is the minimum number of element comparisons required to find an integer in the list that is NOT the largest in the list?
Correct : a
The correct answer is Option A - 1.
This is a beautifully simple question once you see the trick. We need to find any element that is not the largest - we don''t need to find the maximum or sort anything.
Here''s all you need to do: pick any two elements from the list and compare them. Since all integers are distinct, one will be strictly smaller than the other. That smaller element is guaranteed to not be the largest in the entire list - because the element it was just compared to is already larger than it.
So with just 1 comparison, we''ve identified an element that is not the largest.
Options B (N-1), C (N), and D (2N-1) would all be answers if we were trying to find the maximum element. But since we only need any non-largest element, a single comparison is all it takes.
Similar Questions
Total Unique Visitors