GATE Computer ScienceEasyGATE CS (PYQ pattern)

Binary search on a sorted array of 1000 distinct keys uses mid = ⌊(lo + hi)/2⌋ and counts one probe per element compared (the search stops when it probes the key). For how many of the 1000 keys does a successful search take exactly 10 probes?

  1. A. 512
  2. B. 489
  3. C. 488
  4. D. 500

Correct answer: B. 489

The implicit search tree is filled level by level: level k holds 2^(k−1) keys, so levels 1–9 hold 1 + 2 + … + 256 = 511 keys. The remaining 1000 − 511 = 489 keys are on level 10 (maximum 10 probes). 512 is the capacity of level 10, not its occupancy.

More Algorithms questions

Exams that ask this topic