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 / the practitioner

Just start on the first floor and throw the egg. If it
breaks then X=1
If not then go to the second floor and throw the egg. If it
breaks then X=2
If not then go to the third floor and throw the egg. If it
breaks then X=3
If not then keep doing that and the floor it breaks on is
the floor that X equals.
But really, in real life, a real egg would break from 3
feet.

Is This Answer Correct ?    0 Yes 31 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a keyword?

740


Explain how do you list a file’s date and time?

615


Explain how can I read and write comma-delimited text?

646


a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list

629


What is echo in c programming?

551






Write a program to implement queue.

656


Can we assign integer value to char in c?

609


What is structure packing in c?

601


State the difference between realloc and free.

624


Write a code of a general series where the next element is the sum of last k terms.

585


What are the uses of null pointers?

588


Why functions are used in c?

580


What is c basic?

591


What does 4d mean in c?

933


What are local static variables? How can you use them?

638