GATE Computer ScienceHardGATE CSE · NIELIT

To find both the largest and the second-largest among 16 distinct numbers, a knockout tournament is played and then the second-largest is found among those who lost directly to the winner. Using the minimum possible number of comparisons for this method, how many comparisons are needed in the worst case?

  1. A. 19
  2. B. 20
  3. C. 17
  4. D. 18

Correct answer: D. 18

Tournament: n − 1 = 15 comparisons. The winner has played log₂16 = 4 opponents; finding the best of 4 takes 3 more. Total 18 (= n + log₂n − 2).

More Programming and Data Structures (GATE) questions

Exams that ask this topic