Re: Help with an algorithm
Well I am not going to just write the code for you.
I suggest you google for a 'binary search' example in whichever language you are using.
However I am still not sure this is what was asked.
You did say you had 2 balls, perhaps if you only had 2 balls you might not be able to de a binary search cos you could break them both before you find the apropriate floor.
Perhaps what you have to do (and I don't know the rules of your problem) is start on the 2nd floor and drop a ball, if it doesn't break, drop a ball on the 4th floor etc dropping your 1st ball on every 2nd floor (2n) , untill it broke, then dropping the 2nd ball on that floor -1 (2n -1, where n is the attempt that the first ball broke). So if the second ball breaks you know it was that floor, and if it doesn't you know it was the one above that the 1st ball broke on.
Hope that helps (and makes sence)
Maui