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

stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

1953


What is auto keyword in c?

863


What are control structures? What are the different types?

691


What are enumerated types?

743


What is #ifdef ? What is its application?

737






What are multibyte characters?

736


What is the right type to use for boolean values in c?

697


Explain the difference between the local variable and global variable in c?

703


What is the condition that is applied with ?: Operator?

746


What is pass by value in c?

684


What is the difference between printf and scanf in c?

866


Write a program of prime number using recursion.

709


Write the control statements in C language

739


What is the ANSI C Standard?

873


Why is c called "mother" language?

948