GATE Computer ScienceHardGATE CSE · ISRO

What is the minimum number of comparisons needed in the worst case to find both the maximum and the minimum of 101 distinct numbers using the best known pairing strategy?

  1. A. 200
  2. B. 148
  3. C. 150
  4. D. 152

Correct answer: C. 150

Compare elements in pairs (50 comparisons), initialise with the odd element, then 3 comparisons per pair thereafter: ⌈3n/2⌉ − 2 = ⌈151.5⌉ − 2 = 150.

More Programming and Data Structures (GATE) questions

Exams that ask this topic