Monday 12 November 2012

8 ball puzzle select heavier from them....

  Adjust the font size     Reset ↕

Question:

You have eight balls all of the same size. 6 of them weigh the same, and two of them weighs slightly more. How can you find the balls that is heavier by using a balance and do this in minimum number of steps?



Solution:


divide the 8 balls in 3 groups
say .. group A => 3 balls
group B=> 3 balls
group C =>2 balls
put group a and b on balance ..
case 1) A = B .. implies either both a and b have the one heavy ball or group c have both the balls
so choose any two balls from any one of the group ie. A or B (suppose i chose group A) and weigh them against group C ..
if (the balance balances)
{
that means the third ball of group A is heavier one and the other heavy ball is in group B .. so to get it choose any two balls from group B and weigh them against each other ..
if (they are equal)
{that means its the third ball of group B..}
else
{its the one which is giving more weight on balance ..}
}
else if (the side with group C on it is heavier)
{ both the balls of group C are heavy balls .. the required balls ..
THIS IS THE BEST CASE }
else // side with group A's balls is heavier
{
this means one of the two balls are heavier .. (THIS IS THE WORST CASE)
now weigh both balls against each other u will get one heavy ball ..
for next heavy ball take any two balls from group B and weigh them .. if they are equal then its the third ball otherwise which ever is heavier ...
}
Case 2) side with A is heavier ..this means either one heavy ball is in A and another in C or both are in A ...now take 2 balls from A and weigh them against group C
if(balance balances)
{
this means each side has one heavy ball .. now in each of these groups weigh one ball against another to get the heavy balls .. THIS IS ALSO WORST CASE
}
else if(side with C on it is heavier)
{
weigh the balls of C against each other .. if equal means these are the two required balls .. if not then u will get one heavy ball and the other heavy ball is the third ball of group A ..
}
else
{
weigh the two balls of group A .. if equal then they are the required ones .. if not then u will get one heavy ball and the other heavy ball is the third ball of group A...
}
Case 3) side with B is heavier .. same as case (2) ..
FINALLY,
for BEST CASE => 2 comparisions
for AVERAGE CASE => 3 comparisions
for WORST CASE => 4 comparisions ..


POST YOUR OPINION IF YOU HAVE BETTER SOLUTION

Click Here To add Comment

Your feedback is always appreciated.
I will try to reply to your queries as soon as time allows.
Please do not spam Spam comments will be deleted immediately upon our review.

Blogger Widgets

Recent comments

Send Quick Massage

Name

Email *

Message *

Recent posts

Total Pageviews

Blog Archive