If egg doesn t break we go to 27th floor.
Eggs and floors dynamic programming java.
Wiki for dynamic programming.
4 we first try from 4 th floor.
This problem is a specific case of n eggs and k floors.
If egg doesn t break on 27 th floor we go to 39 th floor.
Base cases eggs 1 floors x.
K 10 output.
Given 2 eggs and k floors find the minimum number of trials needed in worst case.
The problem is not actually to find the critical floor but merely to decide floors from which eggs should be dropped so that total number of trials are minimized.
If egg breaks we one by one try remaining 13 floors.
Suppose 2 eggs are available.
Play safe and drop from floor 1 if egg does not break then drop from floor 2 and so on.
Try dropping an egg from each floor from 1 to k and calculate the minimum number of dropping needed in worst case.
Java programming egg dropping puzzle dynamic programming description of instance of this famous puzzle involving n 2 eggs and building with k 36 floors the following is a description of the instance of this famous puzzle involving n 2 eggs and a building with k 36 floors.
Two cases arise 1 if egg breaks we have one egg left so we need three more trials.
If egg breaks on 27 th floor we try floors form 15 to 26.
See below for programming solution for general k eggs and n floors.
What is the least number of egg droppings that is guaranteed to work in all cases.
So egg dropping puzzle has both properties see this and this of a dynamic programming problem.
N eggs k floors.