Monday, 12 November 2012
Tuesday, 9 October 2012
2 eggs dropped from 100th floor with Best solution
Problem Statement:
There is a building of 100 floors. If an egg drops from the Nth floor or above it
will break. If it’s dropped from any floor below, it will not break. You’re given 2 eggs. Find N, while minimizing the number of drops for the worse case.
Solution:Observation: Regardless of how we drop Egg1, Egg2 must do a linear search. Eg, if the Egg1
breaks between floor 10 and 15, we have to check every floor in between with the Egg2
The Approach:
A First Try: Suppose we drop an egg from the 10th floor, then the 20th, …
»» In the first egg breaks on the first drop (Floor 10), then we have at most 10 drops total.
»» If the first egg breaks on the last drop (Floor 100), then we have at most 19 drops total
(floors 1 through 100, then 91 through 99).

