Best way to search for a saturation value in a sorted list
Posted
by AB Kolan
on Stack Overflow
See other posts from Stack Overflow
or by AB Kolan
Published on 2009-03-07T14:24:09Z
Indexed on
2010/06/14
8:42 UTC
Read the original article
Hit count: 223
A question from Math Battle. This particular question was also asked to me in one of my job interviews.
" A monkey has two coconuts. It is fooling around by throwing coconut down from the balconies of M-storey building. The monkey wants to know the lowest floor when coconut is broken. What is the minimal number of attempts needed to establish that fact? "
Conditions: if a coconut is broken, you cannot reuse the same. You are left with only with the other coconut
Possible approaches/strategies I can think of are
- Binary break ups & once you find the floor on which the coconut breaks use upcounting from the last found Binary break up lower index.
- Window/Slices of smaller sets of floors & use binary break up within the Window/Slice (but on the down side this would require a Slicing algorithm of it's own.)
Wondering if there are any other way to do this.
© Stack Overflow or respective owner