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

How can I call fortran?

647


What is difference between structure and union with example?

601


What is static and volatile in c?

785


Explain what is a program flowchart and explain how does it help in writing a program?

653


What is an auto keyword in c?

645






What is exit() function?

563


Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

839


Explain what is the difference between the expression '++a' and 'a++'?

629


What is the full form of getch?

587


In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping

983


any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above

663


List the difference between a 'copy constructor' and a 'assignment operator' in C?

645


What are c identifiers?

631


Write the test cases for checking a variable having value in range -10.0 to +10.0?

1822


What are the primitive data types in c?

579