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


Please Help Members By Posting Answers For Below Questions

How can I invoke another program or command and trap its output?

621


main() { printf("hello"); fork(); }

703


What is getch c?

863


What is the explanation for modular programming?

691


When should a far pointer be used?

609






Explain pointer. What are function pointers in C?

632


2) Write a program that will help Air Traffic Control for an airport to view the sequence of flights ready for take-off. The airport can accommodate 10 flights waiting for take-off at any point in time. Each flight has a unique 3 digit numeric identifier.  Each time a flight takes-off, Air Traffic Control adds a flight to the waitlist. Each time a flight is added to the waitlist, the list of flights waiting to take-off must be displayed.  When a flight is cleared for take-off, Air Traffic Control removes the flight from the waitlist. Each time a flight takes-off, the list of flights waiting to take-off must be displayed.  Sequence of take-off is the sequence of addition to the waitlist

2523


What is the difference between c &c++?

652


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

671


What is difference between array and structure in c?

585


What is c++ used for today?

681


What is the method to save data in stack data structure type?

613


What is a lookup table in c?

633


explain what are actual arguments?

641


Is fortran still used in 2018?

601