There is a 100-story building and you are given two eggs.
The eggs (and the building) have an interesting property
that if you throw the egg from a floor number less than X,
it will not break. And it will always brake if the floor
number is equal or greater than X. Assuming that you can
reuse the eggs which didn't broke; you got to find X in a
minimal number of throws. Give an algorithm to find X in
minimal number of throws.
Answer Posted / ashutosh tiwari
Go to the middle floor, 50 in this case; drop egg, if breaks
go to middle of 1st and 50th i.e. 25th floor otherwise go to
middle of 50 and 100 i.e. 75th floor.
Keep on repeating the method to find the floor in minimum
iteration or egg breaking.
Hope this helps..!!!
| Is This Answer Correct ? | 5 Yes | 25 No |
Post New Answer View All Answers
What does double pointer mean in c?
Can we declare variable anywhere in c?
Explain the use of 'auto' keyword
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.
What is null in c?
How can you allocate arrays or structures bigger than 64K?
Under what circumstances does a name clash occur?
What is a c token and types of c tokens?
Write a program to generate the Fibinocci Series
Why can arithmetic operations not be performed on void pointers?
What are pointers really good for, anyway?
How can I find the modification date of a file?
Difference between linking and loading?
Is c procedural or functional?
Write a program on swapping (100, 50)