Preface
This problem was inspired by a similar question last week on SO, that got deleted before it was clear what the real question was. I think this
The sub-optimal solution for the infinite problem for two eggs is to use the sequence 1, 2^2, 3^3,... ,i^2,...
and start the second edge where the last value the first egg remains. So if the first edge remains at n^2
, then the next one will do at most 2*n + 1 - 1
(minus 1 from the first) test to give the total of 3 * n
in the worst case with n = sqrt(m)
.
There is a simple method that has O(sqrt(f*)) complexity. Make your nth step to be n floors up, that is, check floors 1, 3 (1 + 2), 6 (1 + 2 + 3), etc. This way at the nth step you will be on n*(n+1)/2 floor, and you will reach f* in n = O(sqrt(f*)) steps.
Then for the second egg you will need to go n single steps over your last step in stage 1, which will add another O(sqrt(f*)).
If O(sqrt(k)) was optimal for known k, this method has to be optimal in terms of complexity, too.