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 / basvaraj s pinna

We should start from the second floor to identify the X
floor.

Step 1. Throw the one egg from second floor,
if it breaks in second floor then go to first floor,
through remaining one from the first floor
if it breaks on the first floor then X=1
else
X=2

If does not break in second floor, goto fourth floor and
throw the egg
if it breaks in fourth floor then go to third floor,
through the remaining egg from the third floor
if it breaks on the third floor then X=3
else
X=4

Similarly we should run floor = floor + 2, till one egg
breaks,

floor = floor + 2
if one egg breaks at floor then
Set currentfloor = floor -1 and check for remaining egg
throw from currentfloor, if egg breaks at currentfloor,
then X= currentfloor else X=floor
Else
floor = floor + 2

do until floor =100

Is This Answer Correct ?    10 Yes 55 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f

2158


Can we replace the struct function in tree syntax with a union?

1312


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

1089


What is wild pointer in c with example?

1064


Can we access the array using a pointer in c language?

1051


what are # pragma staments?

2047


What is 1d array in c?

1096


How to write a multi-statement macro?

1050


What are the types of data structures in c?

1157


What is keyword with example?

1070


Explain how can you tell whether a program was compiled using c versus c++?

1105


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

1382


Explain the difference between malloc() and calloc() function?

1058


how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?

1947


Difference between linking and loading?

1116