Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / j1g54w h4ck3r

Find a number n such that n(n+1)/2>=99. (You'll know why
later). n=14 in this case.
Throw one egg from 14th floor.
If it breaks,
start throwing the other egg starting from the 1st floor,
bottom up till it breaks. Max no of throws(worst case)=1+13=14.
else Throw the egg from (14+13)= 27th floor. If it breaks
start throwing the other egg from 15th floor bottom up. Max
no of throws=2+12=14.
Continue till you find the floor.
In the worst case, you'll have to do 14trials compared to
the rather large figures provided by other solutions.
Regards,
J1g54w H4ck3r

Is This Answer Correct ?    71 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I prevent another program from modifying part of a file that I am modifying?

1012


Write a program to print factorial of given number without using recursion?

953


Explain how can you determine the size of an allocated portion of memory?

1044


what is a constant pointer in C

1098


Are there any problems with performing mathematical operations on different variable types?

993


How can you avoid including a header more than once?

930


What is 1d array in c?

1032


What are the applications of c language?

1014


When should we use pointers in a c program?

1083


code for quick sort?

1989


What is malloc() function?

1100


Tell me when is a void pointer used?

1105


What does a pointer variable always consist of?

1045


How can a process change an environment variable in its caller?

1132


What do you mean by Recursion Function?

1073