Microsoft Interview Question
SDETsCountry: United States
Actually I found the problem statement which I believe is the same problem asked here:
8 ball problem. if given 8 balls with only one ball being a
lighter weight and all other 7 being the same weight and
given a scale, how will you find the light weight ball. do
this in minimum number of steps
My initial thought is to divide an conquer which gives
log(N)/log(2)
so in case of 8-ball, it would be
log(8)/log(2) = 3 steps
, but you mentioned it can be done in two steps.
The above would be true depending on the meaning of 'scale'.
- If scale allows you to weigh one group at a time( ex Think of weighing yourself on scale, only one person at a time makes sense ), then I believe
log(8)/log(2)
would be true.
- If scale allows you to weight two group at a time( another type of scale ) then (after cheating and reading answer (see /question?id=8119690) ) they mention the answer is
ceil(log(N)/log(3))
But its only that because they skip the last ball weigh-in using slick process of elimination. So technically they don't weight all the balls.
While this problem is interesting, I'm not a fan of it, especially for a programming interview position( assuming ).
Best.
I have no idea what this question is, can you provide more details on the question?
- tnutty2k8 August 30, 2017