Marble Algorithms Using Discrete Math. During a job interview for a computer science job you are hypothetically given two identical marbles and then asked to figure out the following problem. Find an algorithm which minimizes the maximum number of steps needed to find the smallest floor j so that a marble breaks when dropped from floor j but not from floor j-1 in a skyscraper with 100 floors.

Darius Nash

Darius Nash

Answered question

2022-09-04

Marble Algorithms Using Discrete Math
During a job interview for a computer science job you are hypothetically given two identical marbles and then asked to figure out the following problem. Find an algorithm which minimizes the maximum number of steps needed to find the smallest floor j so that a marble breaks when dropped from floor j but not from floor j 1 in a skyscraper with 100 floors.
I think this problem has to do something with induction. I'm not sure how to start with this problem. Any help would be appreciated.

Answer & Explanation

enreciarpv

enreciarpv

Beginner2022-09-05Added 18 answers

Step 1
The strategy will look like this: We try the first marble from floors n 1 , n 2 , n 3 , , until it breaks from floor n k say. After that the only valid strategy is to try n k 1 + 1 , n k 1 + 2 , , n k 1 (with n 0 = 0 understood) until the second marble breaks (or we have reached the end of the list). So the worst case number of tries if the first marble breaks at n k is k + n k n k 1 . If the overall worst case number is m, this implies n k n k 1 + m k, i.e. n 1 m, n 2 2 m 1, n 3 3 m 3, etc.
Step 2
By induction, n k k m k ( k 1 ) 2 . The maximum of the right hand side is reached at k = m 1 (or k = m) where n m 1 = n m = m ( m + 1 ) 2 . With m = 13 we achieve at most n m = 91 and have no more tries left to distibuish between 92,93,…100. With m = 14 we have n m = 105, which is enough to cover the 100-storey building. Thus our sequence n k is 14,27,39,50,60,69,77,84,90,95,99 and if the first marble survives the 99th floor, we can try the 100th floor immediately and find the answer in 12 tries. But if the first "bad" floor is among the n k , we do need 14 tries.

Do you have a similar question?

Recalculate according to your conditions!

New Questions in Discrete math

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?