/
The  2  eggs  problem (Google interview) The  2  eggs  problem (Google interview)

The 2 eggs problem (Google interview) - PowerPoint Presentation

pasty-toler
pasty-toler . @pasty-toler
Follow
342 views
Uploaded On 2019-06-26

The 2 eggs problem (Google interview) - PPT Presentation

You have a 100story building 2 eggs and you are a busy man Your goal is to find the highest floor from which you can still drop an egg without breaking it Assume that if dropped from below that critical floor an egg always survives while if dropped at or above always breaks ID: 760369

floor egg building step egg floor step building dropped eggs simple approach solutions partitioning equal floors partition complex breaks

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "The 2 eggs problem (Google interview)" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

The 2 eggs problem (Google interview)

You have a 100-story building, 2 eggs, and you are a busy man. Your goal is to find the

highest floor from which you can still drop an egg without breaking it. Assume that if dropped from below that critical floor an egg always survives, while if dropped at or above – always breaks.

Slide2

Approach step-by-step, from simple to more complex solutions.

Slide3

Approach step-by-step, from simple to more complex solutions.

What if you have just one egg? What is the algorithm and the worst case?

What can you do with the second egg?

You can partition the building into, say, 10 block: 1-10, 11-20, … 91-100, drop the 2

nd

egg from floor 10*n, when it breaks, go

one by one from floor 10n -9.

Is this optimal? What if we partition the building as 1-14, 15-28, 29-42… ? Fewer floors in the last interval.

Why equal partitioning of floors? Try equal partitioning of dropped eggs: 1

-14, 15-27,

Slide4

Solution sketch: