Embed Notice
HTML Code
Corresponding Notice
- Embed this notice
mist (ai@cawfee.club)'s status on Thursday, 21-Sep-2023 07:03:03 JSTmist @ceo_of_monoeye_dating @roboneko @mia @p @scenesbycolleen @shibao @MercurialBlack @ExtraSpecialK @meso
Eye agree with what CMD wrote. Let me say the same thing in an unnecessarily confusing way:
I like the "minimax" perspective which says that, since the question is asking about the worst-case scenario, I can imagine that I am playing against an adversary who decides, at each step, whether my egg cracks or survives. (Of course, his decisions must be self-consistent.)
Suppose I choose to drop my first egg at the midpoint N/2. I will be strictly better off in the world where my egg *doesn't* break because I'll have the same number of floors (N/2 - 1) to rule out but one more egg to do it with. Therefore, the adversary will choose to have my egg break.
In the optimal solution, the adversary should be indifferent to every choice which he is faced with. I accomplish this by dropping the first egg lower than N/2. Then, in the world where my egg "does" break, the handicap of having one less egg is balanced out by the advantage of having fewer floors to rule out. Effectively, I am buying insurance.
If the question had asked about the average scenario (w.r.t. some distribution), it would be as if the adversary doesn't play perfectly. It is still advantageous to purchase the insurance, but less insurance is needed because the adversary may fail to exploit my weakness. This intuition tells you that the optimal strategy for the average scenario would involve dropping each egg at a point higher than the "worst case" answer but still lower than N/2.
---
Another perspective is that an answer such as "binary search until the last egg, and then linear search" should set off warning bells because there's no reason why "1 egg" and ">1 eggs" should have such a stark difference.
If there are a lot of eggs (specifically, > log_2(N)), then you obviously do binary search. If there's only 1 egg, then you have to do linear search. It makes sense that the general answer would smoothly interpolate between these two regimes, which it does.
In fact, for E eggs, the number of steps required is O(N^(1/E)), and this order of growth does converge to O(log N) in the limit E -> infinity. (Related fact: geometric mean is the power mean for exponent p = 0, as explained here: https://en.wikipedia.org/wiki/Generalized_mean )