# GATE | GATE-CS-2014-(Set-1) | Question 65

The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is ______________.
(A) 148
(B) 147
(C) 146
(D) 140

Explanation: Steps to find minimum and maximum element out of n numbers:

```1. Pick 2 elements(a, b), compare them. (say a > b)
2. Update min by comparing (min, b)
3. Update max by comparing (max, a)```

Therefore, we need 3 comparisons for each 2 elements, so total number of required comparisons will be (3n)/2 – 2, because we do not need to update min or max in the very first step.

Recurrence relation will be:

`T(n) = T(âŒˆn/2âŒ‰)+T(âŒŠn/2âŒ‹)+2 = 2T(n/2)+2 = âŒˆ3n/2âŒ‰-2`

By putting the value n=100, (3*100/2)-2 = 148 which is answer.

Level Up Your GATE Prep!
Embark on a transformative journey towards GATE success by choosing Data Science & AI as your second paper choice with our specialized course. If you find yourself lost in the vast landscape of the GATE syllabus, our program is the compass you need.

Previous
Next