I am reading Robert Sedgewick's algorithms 4th edition book, and he has the following task:
Suppose that you have an N-story building and 2 eggs. Suppose also that an egg is broken if it is thrown off floor F or higher, and unbroken otherwise. Your cost model is the number of throws. Devise a strategy to determine F such that the number of throws ~c √ F for some constant c.
The first part of the task is to find F in 2 √ N steps, and here's a solution for that:
Solution to Part 1:
He also provides a hint for the ~c √ F part (part 2):
Hint for Part 2: 1 + 2 + 3 + ... k ~ 1/2 k^2.
So what is the algorithm to do it in ~c √ F steps?
Drop first egg from floors 1, 3, 6, ... (the partials sums of 1, 2, 3, ...). Then do linear search between last two floors.