GATE 2015 CS (CS2) – Question 16
An unordered list contains n distinct elements. How many comparisons are needed to find any element that is neither its maximum nor minimum? Assume n≥3.
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (D) $\Theta(1)$
Explanation
Inspect any three elements and return their median, found using at most three comparisons. At least one selected element is smaller and another larger, so this median cannot be a global extreme. The work is independent of n, hence Θ(1), D.
More Asymptotic Analysis and Time/Space Complexity questions
- GATE 2015 CS (CS2) Q26
- GATE 2015 CS (CS3) Q20
- GATE 2015 CS (CS3) Q37
- GATE 2015 CS (CS3) Q41
- GATE 2015 CS (CS3) Q64
- GATE 2021 CS (CS2) Q49
All Asymptotic Analysis and Time/Space Complexity questions →