GATE Computer ScienceVery hardGATE CSE · UGC NET

What is the minimum number of comparisons needed in the worst case to find the SECOND smallest of 100 distinct elements?

  1. A. 101
  2. B. 106
  3. C. 105
  4. D. 198

Correct answer: C. 105

n + ⌈log₂ n⌉ − 2 = 100 + 7 − 2 = 105 using a knockout tournament and then comparing the ⌈log₂ n⌉ elements that lost directly to the winner.

More Algorithms questions

Exams that ask this topic