Imagine you\'re in a tall building with a cat. The cat can survive a fall out of a low story window, but will die if thrown from a high floor. How can you figure out the lon
O(m*(n^(1/m))) algorithm.
Let 'x' be the maximum number of attempts needed.
m = 1 => linear => x=n
m = 2:
Let the floors be split into 'k' partitions. The first cat is thrown at the end of each partition (max 'k' times).
When it dies, the second cat is used to go up from the beginning of this partition.
x = k + n/k.
Minimize x by diff wrt k and setting = 0, to get k = n^(1/2) and x = 2 * n^(1/2).
m = 3:
x = k + 2*(y^(1/2)), where y = n/k
diff wrt x and set = 0, to get k = n^(1/3) and x = 3 * n^(1/3)
for general m:
x = m * n^(1/m).