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
What is the difference between exit() and _exit() function in c?
any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above
Do string constants represent numerical values?
What is cohesion in c?
Write a program for finding factorial of a number.
What is 'bus error'?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
State the difference between realloc and free.
Why is c faster?
What is "Hungarian Notation"?
How can I list all of the predefined identifiers?
What is function prototype?
What is the use of printf() and scanf() functions?
What is a header file?
What are the string functions? List some string functions available in c.