GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A building has 100 floors and you have 2 identical eggs; an egg breaks when dropped from the critical floor or above, and a broken egg cannot be reused. The optimal worst case is 14 drops. For how many different floors x is it possible to make the first drop from floor x and still guarantee at most 14 drops in total?

  1. A. 6
  2. B. 1
  3. C. 14
  4. D. 5

Correct answer: A. 6

If the egg breaks at x, the floors 1…x−1 need x − 1 linear drops, so x − 1 ≤ 13, i.e. x ≤ 14. If it survives, 100 − x floors remain with 2 eggs and 13 drops, which cover at most 13·14/2 = 91 floors, so x ≥ 9. Hence x ∈ {9, …, 14}: 6 choices (verified by DP).

More Algorithms questions

Exams that ask this topic