New Question!!!
Q) There is a building of 100 floors If an egg drops from the Nth floor or above it will break. If it’s dropped from any floor below, it will not break. You’re given 2 eggs. Find N, while minimizing the number of drops for the worst case.
_
#Quality_Answers ;)
Answers
Let us make our first attempt on x'th floor.
If it breaks, we try remaining (x-1) floors one by one.
So in worst case, we make x trials.
If it doesn’t break, we jump (x-1) floors (Because we have
already made one attempt and we don't want to go beyond
x attempts. Therefore (x-1) attempts are available),
Next floor we try is floor x + (x-1)
Similarly, if this drop does not break, next need to jump
up to floor x + (x-1) + (x-2), then x + (x-1) + (x-2) + (x-3)
and so on.
Since the last floor to be tried is 100'th floor, sum of
series should be 100 for optimal value of x.
x + (x-1) + (x-2) + (x-3) + .... + 1 = 100
x(x+1)/2 = 100
x = 13.651
Therefore, we start trying from 14'th floor. If Egg breaks
we one by one try remaining 13 floors. If egg doesn't break
we go to 27th floor.
If egg breaks on 27'th floor, we try floors form 15 to 26.
If egg doesn't break on 27'th floor, we go to 39'th floor.
An so on...
HOPE IT'S HELPFUL FOR YOU
Let first start with one egg.
- We have to first find the floor, from where this egg breaks
- We start at the ground floor.
- If the egg breaks there, then we’ve found the right floor. Otherwise, we get to keep our egg,
and
- we can try again with the next higher floor.
- Continuing on like this, the distance we can explore with 1 egg and 'n' tries is given by
Now,
- Let’s use this relationship (1) to solve the two-egg problem,
where we start with 2 eggs and 'n' tries.
- When we drop an egg from a floor and it breaks, we explore the required floor.
- If first egg breaks, then we’re forced to explore the lower floors with second egg and 'n − 1' tries. But if the egg survives, then we can move on to the upper floors with 2 eggs and 'n − 1' tries.
So,
- The total distance that we can explore with 2 eggs and 'n' tries is given by
Now,.
- we can expand the above recurrence relation,
Now,
- we know,
So,
Above relation can be rewritten as
Now,
- RHS is an AP SERIES, so using sum of n terms of AP, we get
Since,
- we have given building of 100 floors, so we have
- Its a quadratic equation in 'n', whose solution is given by
- On substituting the values, we get
So,
- with two eggs, the floor is 14th floor.