GATE CSE 2021 Set 1 Q12: Comparisons needed to find both minimum and maximum
- Algorithms
- 1 mark
- MCQ
- −1/3 if wrong
Question
Let P be an array containing integers. Let be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of elements. Which one of the following choices is correct?
Try it: multiple choice: exactly one correct option
Show answer and explanation
Answer: C (official GATE 2021 final answer key)
Concept used: Processing elements in pairs finds min and max with about comparisons, which is optimal.
First step: Compare each pair first, then the smaller with the current min and the larger with the current max: 3 comparisons per 2 elements.
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2021 Set 1 CS question paper and final answer key, organised by IIT Bombay. Question paper · Answer key
More Algorithms PYQs
- 2026 Session 1 · Q17Solve nested recurrences T1 = 4T1(n/2) + T2, T2 = 5T2(n/4) + log n
- 2026 Session 1 · Q41Shortest paths with at most k edges: two statements
- 2026 Session 1 · Q47Condition forcing a vertex into every minimum vertex cover
- 2026 Session 1 · Q49Cycle and cut properties of MSTs with distinct weights
- 2026 Session 1 · Q50Impossible DFS discovery/finish orderings for a DAG edge
- 2026 Session 1 · Q55Properties of 2-colorable (bipartite) graphs