There are 9 identical looking metal balls. One of them is defective. You have simple mechanical balance to weigh balls.
What is the minimum number of times we have to use balance to find defective ball?
SOLUTION
This puzzle is similar to
Heavy ball puzzle. main difference is We don't know the defective ball is heavier or lighter than other balls. So we can follow the similar approach as in
Heavy ball puzzle.
First take 3 , 3 balls in each side of balance and keep 3 balls aside
{1,2,3}(left side) -- {4,5,6}(right side) {7,8,9}(kept aside)
CASE-1
If balance is equal on both sides then one of {7,8,9} is defective
then in iteration-2
keep one one ball on each side of balance and keep one aside
{7}(left side) -- {8}(right side) {9}(kept aside)
=>if balance are equal , 9 is defective ball (So in this case in two iterations we can defective ball)
=>if balance is unequal, then one of 7,8 is defective but we can't find which is defective
so in iteration-3 we compare one of 7,8 with any one of good ball
{7}(left side) -- {9}(right side)
Now if balance is equal 8 is defective otherwise 7 is defective
CASE-2
if balance is unequal then defective ball is in one of these two sets {1,2,3},{4,5,6}
To find which set has defective ball , compare it with good ball set {7,8,9}
{1,2,3}(left side) -- {7,8,9}(right side)
=> if balance is equal then defective ball is in {4,5,6} else defective ball is in {1,2,3}
Now apply same logic explained in case-1 on defective set to find defective ball
So in best case it takes 2 iterations to find defective ball, but in worst case it takes 4 iterations.
This puzzle can be extended to find the defective ball is either heavier or lighter.
No comments:
Post a Comment