SlideShare a Scribd company logo
THE EGG DROPPING PROBLEM
MOHAMMAD ALETAHA
SHARIF UNIVERSITY OFTECHNOLOGY
1
WHYTHIS PROBLEM?
Known as a Google and Microsoft interview test
The question maker is unknown
2
THE PROBLEM
We have 2 eggs and a 100 floors
What is the min attempt? (worst case)
3
DEFINITION
We have k numbers of eggs and a building with n floors.
What is the least number of egg-dropping attempts that
is guaranteed to find the highest floor from witch the
egg won’t break on dropping?
4
NOTES
What strategy minimizes the number of attemps?
We can break the eggs during attempts
No tipping point exist! (mathematical sol’n)
5
TRIVIAL PROBLEMS
given one egg and ten floors
What is min attempt? (worst case)
Ans: 10
given ten egg and one floors
What is min attempt? (worst case)
Ans: 1
6
SUBPROBLEMS
Given many eggs
Idea: binary tree
e.g. 100 floors
Max attemps: 7
7
BACKTO MAIN
2 eggs and a 100 floors
Idea: 10 floors interval
Worst case?
19 attempt for 99
10,20,…,100 (10 att) + 91,…,99 (9 att)
8
ANOTHER STRATEGY
Idea: bigger intervals
e.g. size of intervals = 12
Worst case?
19 attempts for 95
12,24,...,84,96 (8 att) + 84,…,95 (11 att)
9
NOTE
In two last strategy:
Attempts are not identical for different numbers
e.g. 2 eggs, 100 floors:
for 24, 8 att & for 80, 9 att
10
BETTER STRATEGY
Idea: change intervals
Decreasing from x to 1 (optimizing x)
x + (x-1) + (x-2) + (x-3) + (x-4) + … + 1 >= n
For 10 floors x is 4
For 100 floors x is 14
11
INDENTICAL ATTEMPTS
12
GENERALIZING
Function: Drop(total floors, total eggs)
We have to complete such a table:
13
DYNAMIC PROGRAMMING
We call Drop(n,k) recursively
Basic cases:
- Drop(1,x)=1
- Drop(x,1)=x
floor we are currently attempting to drop from is
represented by f
14
DYNAMIC PROGRAMMING
If we drop an egg from floor f, one of two events happens:
- Case 1: egg breaks:
our problem is reduced to a tower of height f-1, and we now
have k-1 eggs
- Case 2: egg doesn’t break:
we need to check n-f floors and we still have k eggs
15
EXAMPLE
16
FORMULATION
17
C++
IMPLEMENTATION
18
19
Thanks for your attention!
20

More Related Content

What's hot

Tsp branch and-bound
Tsp branch and-boundTsp branch and-bound
Tsp branch and-bound
Saravanan Natarajan
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
Fahim Ferdous
 
Chapter 11: Data Link Control
Chapter 11: Data Link ControlChapter 11: Data Link Control
Chapter 11: Data Link Control
JeoffnaRuth
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
Rajendran
 
Data Link Layer| Error Detection
Data Link Layer| Error DetectionData Link Layer| Error Detection
Data Link Layer| Error Detection
Taimoor Muzaffar Gondal
 
Data mining techniques
Data mining techniquesData mining techniques
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
DurgeshPratapSIngh8
 
Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking 
Hasanain Alshadoodee
 
Chapter 21
Chapter 21Chapter 21
Chapter 21
Faisal Mehmood
 
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...
Rohan Byanjankar
 
Forward error correction
Forward error correctionForward error correction
Forward error correction
Prankit Mishra
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
Faisal Mehmood
 
Travelling Salesman Problem
Travelling Salesman ProblemTravelling Salesman Problem
Travelling Salesman ProblemDaniel Raditya
 
Lzw compression
Lzw compressionLzw compression
Lzw compression
Meghna Singh
 
Decision Tree and Bayesian Classification
Decision Tree and Bayesian ClassificationDecision Tree and Bayesian Classification
Decision Tree and Bayesian Classification
Komal Kotak
 
Congestion control in TCP
Congestion control in TCPCongestion control in TCP
Congestion control in TCP
selvakumar_b1985
 
HTTP & WWW
HTTP & WWWHTTP & WWW
HTTP & WWW
RazanAlsaif
 
Error Detection & Error Correction Codes
Error Detection & Error Correction CodesError Detection & Error Correction Codes
Error Detection & Error Correction Codes
ShahDhruv21
 
Fuzzy Set
Fuzzy SetFuzzy Set
Fuzzy Set
Ehsan Hamzei
 

What's hot (20)

Tsp branch and-bound
Tsp branch and-boundTsp branch and-bound
Tsp branch and-bound
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
 
Chapter 11: Data Link Control
Chapter 11: Data Link ControlChapter 11: Data Link Control
Chapter 11: Data Link Control
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
 
Data Link Layer| Error Detection
Data Link Layer| Error DetectionData Link Layer| Error Detection
Data Link Layer| Error Detection
 
Data mining techniques
Data mining techniquesData mining techniques
Data mining techniques
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking 
 
Chapter 21
Chapter 21Chapter 21
Chapter 21
 
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...
Concept of Relational Database and Integrity Constraints [DIFFERENCE BETWEEN ...
 
Forward error correction
Forward error correctionForward error correction
Forward error correction
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
Travelling Salesman Problem
Travelling Salesman ProblemTravelling Salesman Problem
Travelling Salesman Problem
 
Assosiate rule mining
Assosiate rule miningAssosiate rule mining
Assosiate rule mining
 
Lzw compression
Lzw compressionLzw compression
Lzw compression
 
Decision Tree and Bayesian Classification
Decision Tree and Bayesian ClassificationDecision Tree and Bayesian Classification
Decision Tree and Bayesian Classification
 
Congestion control in TCP
Congestion control in TCPCongestion control in TCP
Congestion control in TCP
 
HTTP & WWW
HTTP & WWWHTTP & WWW
HTTP & WWW
 
Error Detection & Error Correction Codes
Error Detection & Error Correction CodesError Detection & Error Correction Codes
Error Detection & Error Correction Codes
 
Fuzzy Set
Fuzzy SetFuzzy Set
Fuzzy Set
 

Similar to The Egg Dropping Problem

Ml presentation
Ml presentationMl presentation
Ml presentation
Mark Fetherolf
 
Ensembles of Many Diverse Weak Defenses can be Strong: Defending Deep Neural ...
Ensembles of Many Diverse Weak Defenses can be Strong: Defending Deep Neural ...Ensembles of Many Diverse Weak Defenses can be Strong: Defending Deep Neural ...
Ensembles of Many Diverse Weak Defenses can be Strong: Defending Deep Neural ...
Pooyan Jamshidi
 
Chapter 4 Special Discrete Distribution.pptx
Chapter 4 Special Discrete Distribution.pptxChapter 4 Special Discrete Distribution.pptx
Chapter 4 Special Discrete Distribution.pptx
amopro5198
 
Lec 06
Lec 06Lec 06
Lec 06
Nilt1234
 
Maths formula by viveksingh698@gmail.com
Maths formula by viveksingh698@gmail.comMaths formula by viveksingh698@gmail.com
Maths formula by viveksingh698@gmail.com
vivek698
 
Day 7 distributive property
Day 7 distributive propertyDay 7 distributive property
Day 7 distributive propertyErik Tjersland
 
Multiplying Polynomials
Multiplying PolynomialsMultiplying Polynomials
Multiplying Polynomials
JonathanSantos232
 
Chapter 5 2022.pdf
Chapter 5 2022.pdfChapter 5 2022.pdf
Chapter 5 2022.pdf
Mohamed Ali
 
Taylor and maclaurian series
Taylor and maclaurian seriesTaylor and maclaurian series
Taylor and maclaurian series
Nishant Patel
 
vedic mathematics
vedic mathematics vedic mathematics
vedic mathematics
Nitin Chhaperwal
 

Similar to The Egg Dropping Problem (12)

Ml presentation
Ml presentationMl presentation
Ml presentation
 
Ensembles of Many Diverse Weak Defenses can be Strong: Defending Deep Neural ...
Ensembles of Many Diverse Weak Defenses can be Strong: Defending Deep Neural ...Ensembles of Many Diverse Weak Defenses can be Strong: Defending Deep Neural ...
Ensembles of Many Diverse Weak Defenses can be Strong: Defending Deep Neural ...
 
Chapter 4 Special Discrete Distribution.pptx
Chapter 4 Special Discrete Distribution.pptxChapter 4 Special Discrete Distribution.pptx
Chapter 4 Special Discrete Distribution.pptx
 
Lec 06
Lec 06Lec 06
Lec 06
 
Maths formula by viveksingh698@gmail.com
Maths formula by viveksingh698@gmail.comMaths formula by viveksingh698@gmail.com
Maths formula by viveksingh698@gmail.com
 
Np cooks theorem
Np cooks theoremNp cooks theorem
Np cooks theorem
 
Day 7 distributive property
Day 7 distributive propertyDay 7 distributive property
Day 7 distributive property
 
Multiplying Polynomials
Multiplying PolynomialsMultiplying Polynomials
Multiplying Polynomials
 
Chapter 5 2022.pdf
Chapter 5 2022.pdfChapter 5 2022.pdf
Chapter 5 2022.pdf
 
Abhinav
AbhinavAbhinav
Abhinav
 
Taylor and maclaurian series
Taylor and maclaurian seriesTaylor and maclaurian series
Taylor and maclaurian series
 
vedic mathematics
vedic mathematics vedic mathematics
vedic mathematics
 

Recently uploaded

nodule formation by alisha dewangan.pptx
nodule formation by alisha dewangan.pptxnodule formation by alisha dewangan.pptx
nodule formation by alisha dewangan.pptx
alishadewangan1
 
Orion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWSOrion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWS
Columbia Weather Systems
 
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Studia Poinsotiana
 
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdfDMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
fafyfskhan251kmf
 
Seminar of U.V. Spectroscopy by SAMIR PANDA
 Seminar of U.V. Spectroscopy by SAMIR PANDA Seminar of U.V. Spectroscopy by SAMIR PANDA
Seminar of U.V. Spectroscopy by SAMIR PANDA
SAMIR PANDA
 
GBSN - Microbiology (Lab 4) Culture Media
GBSN - Microbiology (Lab 4) Culture MediaGBSN - Microbiology (Lab 4) Culture Media
GBSN - Microbiology (Lab 4) Culture Media
Areesha Ahmad
 
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Sérgio Sacani
 
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Sérgio Sacani
 
Lateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensiveLateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensive
silvermistyshot
 
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
Wasswaderrick3
 
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdfMudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
frank0071
 
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
University of Maribor
 
role of pramana in research.pptx in science
role of pramana in research.pptx in sciencerole of pramana in research.pptx in science
role of pramana in research.pptx in science
sonaliswain16
 
Toxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and ArsenicToxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and Arsenic
sanjana502982
 
Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.
Nistarini College, Purulia (W.B) India
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
RenuJangid3
 
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
yqqaatn0
 
In silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptxIn silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptx
AlaminAfendy1
 
S.1 chemistry scheme term 2 for ordinary level
S.1 chemistry scheme term 2 for ordinary levelS.1 chemistry scheme term 2 for ordinary level
S.1 chemistry scheme term 2 for ordinary level
ronaldlakony0
 
in vitro propagation of plants lecture note.pptx
in vitro propagation of plants lecture note.pptxin vitro propagation of plants lecture note.pptx
in vitro propagation of plants lecture note.pptx
yusufzako14
 

Recently uploaded (20)

nodule formation by alisha dewangan.pptx
nodule formation by alisha dewangan.pptxnodule formation by alisha dewangan.pptx
nodule formation by alisha dewangan.pptx
 
Orion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWSOrion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWS
 
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
 
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdfDMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
 
Seminar of U.V. Spectroscopy by SAMIR PANDA
 Seminar of U.V. Spectroscopy by SAMIR PANDA Seminar of U.V. Spectroscopy by SAMIR PANDA
Seminar of U.V. Spectroscopy by SAMIR PANDA
 
GBSN - Microbiology (Lab 4) Culture Media
GBSN - Microbiology (Lab 4) Culture MediaGBSN - Microbiology (Lab 4) Culture Media
GBSN - Microbiology (Lab 4) Culture Media
 
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
 
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
 
Lateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensiveLateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensive
 
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
 
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdfMudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
 
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
 
role of pramana in research.pptx in science
role of pramana in research.pptx in sciencerole of pramana in research.pptx in science
role of pramana in research.pptx in science
 
Toxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and ArsenicToxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and Arsenic
 
Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
 
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
 
In silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptxIn silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptx
 
S.1 chemistry scheme term 2 for ordinary level
S.1 chemistry scheme term 2 for ordinary levelS.1 chemistry scheme term 2 for ordinary level
S.1 chemistry scheme term 2 for ordinary level
 
in vitro propagation of plants lecture note.pptx
in vitro propagation of plants lecture note.pptxin vitro propagation of plants lecture note.pptx
in vitro propagation of plants lecture note.pptx
 

The Egg Dropping Problem