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 s c mean on snapchat?
What does %c do in c?
What are the types of pointers in c?
Explain how can I remove the trailing spaces from a string?
What is type qualifiers?
What is the use of volatile?
Write a c program to build a heap method using Pointer to function and pointer to structure ?
What is binary tree in c?
What is wild pointer in c?
Differentiate between calloc and malloc.
What are enums in c?
What is d'n in c?
What is the difference between constant pointer and constant variable?
Differentiate between Macro and ordinary definition.
What are the ways to a null pointer can use in c programming language?