Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 03-18-2005, 06:07 PM   #1 (permalink)
 
Newb Techie

Join Date: Mar 2005

Posts: 3

manu2011

Default help with algorithm

hello everyone,
please help me with this :

Suppose given two identical crystal balls and n stories building. the goal is to find the least floor so that if you throw the ball from this floor, the ball will break. the rules are:

the two balls break at the same floors.
if a ball breaks at floor i it also breaks at floor i+1.

i have to design the best algorithm to find the least floor the ball breaks at with minimum number of possible ball throws.

thanks
manu2011 is offline  
Old 03-18-2005, 06:11 PM   #2 (permalink)
 
Newb Techie

Join Date: Mar 2005

Posts: 9

mdhakk

Send a message via AIM to mdhakk
Default

I would assume the best way would be to start dropping one ball from n, the other ball from n-(n-1), and run a counter that subtracts a floor from the first ball and moves the second ball to n-(n-2) ...etc. When the condition for one of the ball changes from broken=true to broken=false or vice versa, you would know which floor is the right floor.
mdhakk is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On