0% found this document useful (0 votes)
24 views

Dynamic Programming 9

The document describes an egg dropping puzzle where the goal is to determine the highest floor of a 36-floor building that an egg can be dropped from without breaking, using up to 2 eggs. It explains the assumptions and provides a dynamic programming approach to solve the problem, defining the problem state and a functional equation to minimize the number of trials needed.

Uploaded by

Arvin Hipolito
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Dynamic Programming 9

The document describes an egg dropping puzzle where the goal is to determine the highest floor of a 36-floor building that an egg can be dropped from without breaking, using up to 2 eggs. It explains the assumptions and provides a dynamic programming approach to solve the problem, defining the problem state and a functional equation to minimize the number of trials needed.

Uploaded by

Arvin Hipolito
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Egg dropping puzzle[edit]

The following is a description of the instance of this famous puzzle involving N=2 eggs and a building
with H=36 floors:[13]
Suppose that we wish to know which stories in a 36-story building are safe to drop eggs
from, and which will cause the eggs to break on landing (using U.S. English terminology, in
which the first floor is at ground level). We make a few assumptions:

 An egg that survives a fall can be used again.


 A broken egg must be discarded.
 The effect of a fall is the same for all eggs.
 If an egg breaks when dropped, then it would break if dropped from a higher window.
 If an egg survives a fall, then it would survive a shorter fall.
 It is not ruled out that the first-floor windows break eggs, nor is it ruled out that eggs can
survive the 36th-floor windows.
If only one egg is available and we wish to be sure of obtaining the right result, the
experiment can be carried out in only one way. Drop the egg from the first-floor window; if it
survives, drop it from the second-floor window. Continue upward until it breaks. In the worst
case, this method may require 36 droppings. Suppose 2 eggs are available. What is the
lowest number of egg-droppings that is guaranteed to work in all cases?
To derive a dynamic programming functional equation for this puzzle, let the state of the
dynamic programming model be a pair s = (n,k), where
n = number of test eggs available, n = 0, 1, 2, 3, ..., N − 1.
k = number of (consecutive) floors yet to be tested, k = 0, 1, 2, ..., H − 1.
For instance, s = (2,6) indicates that two test eggs are available and 6
(consecutive) floors are yet to be tested. The initial state of the process is s =
(N,H) where N denotes the number of test eggs available at the commencement
of the experiment. The process terminates either when there are no more test
eggs (n = 0) or when k = 0, whichever occurs first. If termination occurs at
state s = (0,k) and k > 0, then the test failed.
Now, let
W(n,k) = minimum number of trials required to identify the value of the critical floor under the
worst-case scenario given that the process is in state s = (n,k).
Then it can be shown that[14]
W(n,k) = 1 + min{max(W(n − 1, x − 1), W(n,k − x)): x = 1, 2, ..., k }
with W(n,0) = 0 for all n > 0 and W(1,k) = k for all k. It is easy to solve
this equation iteratively by systematically increasing the values
of n and k.

You might also like