Open In App
Related Articles

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

Improve Article
Save Article
Like Article

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

Answer: (A)

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.


Quiz of this Question

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.

Last Updated : 10 Apr, 2018
Like Article
Save Article
Similar Reads