At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
you have got 32 ball and all of them have different weights and you also have a scale to weigh them.What is the minimum number of weighings in which you can find the second heaviest ball?
The questions gives away a few hints. The number of balls is a power of 2, and an arbitrary one at that. Can we generalise this for a given power of 2?
Or better yet, can it be done for any \(n\)?
1 ball: does not apply. 2 balls: one time. 3 balls: two times. 4 balls: three times. (Right?)
OK, so suppose that we have a collection of \(n\) balls. Is it true that with \(n+1\) balls, we would need only one more weight?
Or better yet, if we have a collection of \(n\) balls whose second-highest weight is known, and we add another ball to it, would it be possible to determine if the newly added weight is the second-highest weight in only one weighing?
hey guys so heres the answer 1st - we divide the balls into pair of 2s and therefore we get 16 pairs. We weigh the balls of each pair and take the heavier ball from all the pairs. TOTAL WEIGHINGS = 16 2nd-we divide the 16 balls that we got frm above step into pairs of 2s and we get 8 pairs, we weigh each the balls of each pair and take the heavier balls.TOTAL WEIGHINGS = 8 3rd - we divide the 8 balls into pair of 2s and get 4 pairs and weigh them and get the 4 heavier balls.TOTAL WEIGHINGS = 4 4th-we divide the 4 balls into pair of 2s and weigh them and get 2 heaviest balls.TOTAL WEIGHINGS = 2 5TH- we weigh the 2 balls so obtained and get the heaviest ball. TOTAL WEIGHINGS=1 now you might be wondering that we got the heaviest ball and not the second heaviest one. So now heres the way to find it Lets 1st think that how can that second heaviest ball can be eliminated- the only way to eliminate the 2nd heaviest ball is to compete it with the heaviest ball which we got in the 5th step. But there can be a case that the second heaviest ball did not get the chance to compete with the heaviest ball and then it came to the final and got out, so this means that the ball who weighed less in the final was the second heaviest ball. So now to make sure that the ball which weighed less in the final was the second heaviest ball we weigh it with the ball who got eliminated by the heaviest ball in the 1st,2nd,3rd and 4th rounds. If the loser of 5th round weighs less than the balls who got eliminated by heaviest ball, then we'll take that winner ball and we'll compete it with the other balls who got eliminated by the heaviest ball so TOTAL WEIGHINGS= 4 OVERALL TOTAL WEIGHINGS = 16+8+4+2+1+4 = 35
Oh, so it did have to do something with being a power of 2.
This is actually a dynamic programming problem, the answer for general case that parth has started is \[n+\log_2 n-2\]
It seems more like a logic problem, like a mind bender type question.
Oh my, I don't think I'd ever have been able to do that. Haha.
the scale must be a comparison scale
yes the scale was a comparison scale @Miracrown
So this problem can't be solved for an \(n\) that is not a power of 2 because it can have many cases. Hmm.
Here is a slightly easier way to think about this problem in context to dynamic programming : It takes \(n-1\) comparisons to find out the first heaviest ball. And the first heaviest ball is compared against exactly \(\log_2 n\) times : |dw:1433838513485:dw| The second heaviest ball must be one of the \(\log_2 n\) balls that got compared against the first heaviest ball. So it neds \(\log_2n-1\) more comparisons.
this problem can be solved for any \(n\), just replace \(\log_2n\) by \(\lceil \log_2 n\rceil \)
well done @rational
I was reading this - something similar but the question is different ... http://classic-puzzles.blogspot.com.au/2006/12/13-balls-problem-one-of-hardest.html
All your balls are different weights - so you need new logic. I would try putting all the balls into pairs, and doing a weighing of EACH one. and maybe placing them down in a way you remember their partner
yes @Miracrown the link has similar questions but i mixed the question with slight twist.
@Miracrown yes this is the actual approach
Another solution is here... to the same question... but a better answer https://weteachscience.org/mentoring/resources/lesson-plans/eight-balls-weighing-problem-logic
@Miracrown how is the question same :)
Well, the goal is to find "the odd weighted ball" but your question is different. If you combine them all on the scale, there is no guarantee you will have the heaviest of lightest ball in any given set...
The question isn't the same, but the problem is. :)
Actually not really.
That is where the popping of a brain vessel comes in
i didn't combined all the ball nd weighed. what i did was that i weighed 2 balls at a time @Miracrown
Whatever you did, it was SMART