Skip to content

Commit ba27b0b

Browse files
authored
Updates the preamble and description of the readme
1 parent dea3165 commit ba27b0b

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Egg Drop Problem/README.markdown

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
# Egg Drop Dynamic Problem
1+
# Egg Drop
22

3-
## Problem Description
3+
The *egg drop* problem is an interview question popularized by Google. The premise is simple; You're given a task to evaluate the *shatter resistance* of unknown objects by dropping them at a certain height. For simplicity, you test this by going inside a multi-story building and performing tests by dropping the objects out the window and onto the ground:
44

5-
Given some number of floors and some number of eggs, what is the minimum number of attempts it will take to find out from which floor egg will break.
5+
![building with eggs being dropped](images/eggdrop.png)
66

7-
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. We make a few assumptions:
7+
Your goal is to find out the **minimum** height that causes the object to shatter. Consider the trivial case you're given **1** object to obtain the results with. Since you've only got one sample for testing, you need to play it safe by performing drop tests starting with the bottom floor and working your way up:
8+
9+
![dropping from first floor](images/eggdrop2.png)
10+
11+
If the object is incredibly resilient, and you may need to do the testing on the world's tallest building - the [Burj Khalifa](https://en.wikipedia.org/wiki/Burj_Khalifa). With **163** floors, that's a lot of climbing. Let's assume you complain, and your employer hears your plight. You are now given *several* samples to work with. How can you make use of these extra samples to expedite your testing process? The problem for this situation is popularized as the **egg drop** problem.
12+
13+
## Description
14+
15+
You're in a building with **m** floors and you are given **n** eggs. What is the minimum number attempts it will take to find out the lowest floor that breaks the egg?
16+
17+
For convenience, here are a few rules to keep in mind:
818

919
- An egg that survives a fall can be used again.
1020
- A broken egg must be discarded.
1121
- The effect of a fall is the same for all eggs.
12-
- If an egg breaks when dropped, then it would break if dropped from a higher floor.
13-
- If an egg survives a fall then it would survive a shorter fall.
22+
- If an egg breaks, then it would break if dropped from a higher floor.
23+
- If an egg survives, then it would survive a shorter fall.
1424

15-
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 least number of egg-droppings that is guaranteed to work in all cases?
1625
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.
1726

1827
## Solution

0 commit comments

Comments
 (0)