GATE Computer ScienceHardGATE CSE · ISRO

In a knockout (tournament-tree) method, what is the minimum number of comparisons needed in the worst case to find both the smallest and the second smallest of 50 distinct numbers?

  1. A. 49
  2. B. 54
  3. C. 56
  4. D. 98

Correct answer: B. 54

n−1 = 49 comparisons find the minimum; the second smallest is among the ⌈log₂50⌉ = 6 elements that lost directly to the winner, needing 5 more: n + ⌈log₂ n⌉ − 2 = 54.

More Programming and Data Structures (GATE) questions

Exams that ask this topic