Chris has 6 coins of distinct weights and a beam balance with two pans.
Can he find both the heaviest and the lightest coins by using the balance 7 times?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Can this be done using the balance 6 times, or is 7 the best upper bound? Why or why not?
Log in to reply
We can do this in 6 times if we have a weighting machine instead of the beam balance.
Though, frankly speaking we can do it without the balance. A random guess might turn out to be true. But that's all probability. And chances of correct guessing of the order of coins is negligible or, 1/6! .
Thank you!
Log in to reply
We're only asked for the heaviest and the lightest. The probability that a random guess would be correct is (1/6)*(1/5).
Log in to reply
@Richard Desper – Yeah you are right . I thought about the order of the coins.
I have a proof that you can't do better than 5 using a decision tree. Note that the tree has at least n ( n − 1 ) leaves (number of different ordered pairs), so it must have a height of at least ⌈ lo g n ( n − 1 ) ⌉ = 5 . That means we must perform at least 5 comparisons to guarantee an outcome.
How do you go about proving you can't do better than 7?
Log in to reply
I thought intuitively . Can you please prove your point by providing an easy example like Mr. Charlesworth did?
Log in to reply
@Kaushik Chandra – You might lose the big picture if you only look at a specific example. A decision tree is a general method to argue about the lower bound. Here is an example of applying the decision tree to prove the performance of comparison-based sorting algorithms.
Log in to reply
@Christopher Boo – I didn't knew this method. Thanks for sharing :)
Can we actually use this decision tree as it is to describe an algorithm for doing it in 5 steps? We should not require any more information than this 5 bits, because it is irrelevant.
Log in to reply
@Agnishom Chattopadhyay – No. The decision tree only tells us that you can't do better than 5. It does not say that i) you can do it in 5 steps, nor ii) describe an algorithm that can do it in 5 steps.
Log in to reply
@Christopher Boo – Are there cases where one needs an algorithm consisting of strictly larger number of steps than the depth of the decision tree?
Log in to reply
@Agnishom Chattopadhyay – Sorry, I don't really understand your question. Do you mean if there's a set of weights such that the worst case of the best algorithm is more than the depth of the decision tree?
I was about to solve this but then I got scared by his last name
"We then know that the lightest coin will be among" actually I do know nothing , can you please explain how I am supossed to know this. I am stuck betweem the bubble sort and dichotomy. dividing the set in two, smells like dichotomy, and afterwards sorting the two sets in a bubble sorts.
Log in to reply
The lightest coin must weigh less than every other coin. Since each of B , D , F are heavier than at least one of the other coins, none of them can be the lightest, and so one of A , C , E must be the lightest.
Similarly, since the heaviest coin must weigh more than every other coin, and since each of A , C , E are lighter than at least one of the other coins, the heaviest coin must be among B , D , E .
What do you mean by loser?
Log in to reply
The lighter weight is the loser
I think he means that the loser of the heavy pair is the lighter one of the two and the loser of the lighter pair is the heavier one out of the two.
When weighing heavy pile to know which is heavier, light one is loser. When weighing light pile to know which is lighter, heavier one the loser.
I tried in two different random cases I find ur way is best
Thx! I struggled with this one and this helped a lot.
What's a loser: heavy or light?
Imagine a tournament of coins to find the heaviest. It takes one round (3 matches) to eliminate half of the coins (A B C and D E F). Of the remaining three coins (D E F), two matches determine the heaviest (F). Now, to find the lightest, you know it lost the first round, so you use the other half of the coins (A B C) and have another round of two matches to discover it (A).
A variant of this question is to ask how many matches you need to find the second heaviest. Clue: It lost against the heaviest.
In your variant D E F have to be measured 3 times, since if D>E, then D>F, you still don't know if E or F is bigger. So it needs one additional measurement.
Log in to reply
What about the one that F beat in the first round of weighings? How do you know that it isn't the 2nd heaviest?
Log in to reply
Exactly.
In general, you can use a tournament of height h = log n to find the greatest element. And then you have h candidates for second best. So you'll need (n-1) + (log n - 1) to find the second best.
That is a very interesting variant indeed. Maybe you could post it as a problem on Brilliant?
if you set this up as a tournament with five "matches" you'll find the heaviest. to find the lightest take all the losers (3) from the first round and instead advancing the winer (heaviest) you'll advance the loser (lightest). in two matches you should have your answer
Label all coins 1,2,3,4,5,6. Now make pair as (1,2),(3,4),(5,6) The three above pairs are now sent for a dead match ...suppose 1,3,5 wins in the allotted pairs,then (1,3) are sent to dead match...and suppose 3 wins.. Then (3,5) sent for dead match .Finally say,5 wins(Heavy weight champion) So overall we had 5 matches so far... Let's give the failures their "second chance" (1,4) are sent for a dead match ...say 1 wins..now (1 ,6) are the final challengers ..who will the winer,will be the lightest-weight champion... So total seven matches are done..
Let the weights of the 6 coins be A,B,C,D,E,F. Choose a coin in random to be a constant. Now, weigh the other 5 coins against it. The heaviest coin will be the one which causes the biggest tilt and the lightest coin will be the one which causes the smallest tilt.
First, put 3 coins in each pan of the balance. The set with heavier coins will go down. Now we have three coins which contain the heaviest and other 3 which contain the lightest. You now have two options, to weigh the heaviest first or the lightest. It is simple. You just have to first weigh two coins against each other(this activity will be separate for both the sets) and determine the heaviest among them and then repeat this activity for the remaining coin. You still have 4 chances left of using the balance. So repeat this for the other set and you will get the heaviest and the lightest coins!
Not true; it depends upon the differences between the coins. 1g + 2g + 6g < 3g + 4g + 5g, but the heaviest individual value there would appear in the lighter of the 2 groups of 3. You can only say that the set with the heaviest total will go down in your initial weighing.
Log in to reply
I was thinking the same by giving specific values like 1 2 3 4.5 5.5 6 grouping 1 4.5 5.5 eq the group 2 3 6 in sum ...
Example list with 6 weights: a = [8,4,3,9,1,2]
Find the lowest with 5 comparisons:
cmp(8,4) low = 4, hi = 8
cmp(4,3) low = 3, hi = 8
cmp(3,9) low = 3, hi = 8
* remember number 9, the first non-lower number *
cmp(3,1) low = 1, hi = 8
cmp(1,2) low = 1, hi = 8
Found the lowest number=1, with 5 comparisons.
Find the greatest with 2 additional comparisions:
* start from previous number 9, because all the left is lower or equal to 8 *
cmp(8,9) low = 1, hi = 9
* no need to compare to 1, as it's already proved the lowest *
cmp(9,2) low = 1, hi = 9
Found the highest number=9, with 2 additional comparisons.
This can be done with 7 weighings.
1) Randomly create three pairs of coins.
2) Compare each coin pair using the scale. Separate coins that are heavier into a 'heavy' pile and the lighter coins into a 'light' pile (this will require 3 weighings)
3) Select two coins from the 'heavy' pile at random and compare with the scale. Remove the lighter coin from the scale and place the remaining coin from the 'heavy' pile on the scale. The heaviest coin from this weighing is the heaviest of all the original coins (this will require 2 weighings)
4) Select two coins from the 'light' pile at random and compare with the scale. Remove the heavier coin from the scale and place the remaining coin from the 'light' pile on the scale. The lightest coin from this weighing is the lightest of all the original coins (this will require 2 weighings)
Let the weights be A < B < C < D < E < F and the coins be c 1 , c 2 , . . . c 6 . Since we do not know the relationship between the weights of the coins, weighing with more than one coin on a side gives no information. For example, when trying two coins on one side and one on the other, weighing C , E with F may result in either side being heavier than the other because we do not know if C + E is greater or less than F . This will be seen with any other situation where more than one coin is on one side.
Now we weigh two coins, c 1 and c 2 , against each other. Suppose c 1 < c 2 . Now we know c 1 does not weigh F and c 2 does not weigh A . If we weigh one of these two, c 1 for example, with another coin, c 3 , we will find that one cannot be A and the other might be. If we weigh two unrelated coins c 3 and c 4 , we will learn this information, but we will also learn that one cannot be F . Therefore, weighing two new coins gives the most information. We will do the same for the last two coins.
WLOG, we have c 1 < c 2 , c 3 < c 4 , and c 5 < c 6 , and we took 3 separate measurements so far. We know one of c 1 , c 3 , and c 5 weigh A , and one of c 2 , c 4 , and c 6 weigh F . Cross comparing the two groups gives no information about A or F since we already eliminated these weights from each of the groups. We will weigh two of the lighter coins, c 1 and c 3 , and we find that c 1 < c 3 . Now c 3 cannot weigh A . A similar result would occur if we weighed any two of the lighter coins. This alone does not tell us the lightest coin, so at least one more weight is needed. This can be accomplished by weighing the last two coins that might weigh A , c 1 and c 5 . With 2 additional weighings, we found the lightest coin. A very similar method will locate the heaviest coin in the second group with 2 weighings. Therefore, the minimum number of weighings needed to find the lightest and heaviest coins is 3 + 2 + 2 = 7 .
Problem Loading...
Note Loading...
Set Loading...
Let the weights of the 6 coins be A , B , C , D , E , F . Pair them off sequentially onto the beam balance, making a total of 3 weighings. Without loss of generality suppose we find that A < B , C < D and E < F . We then know that the lightest coin will be among A , C and E , and that the heaviest coin will be among B , D and F .
Now weigh A against C . Whichever is the lightest, say A , we then just need to weigh A against E to determine the lightest of all the coins. Similarly, to find the heaviest coin we start by weighing B against D , and then weighing the heaviest of these against F . We have made 4 additional weighing in the process, giving us a total of 7 weighings to determine both the lightest and heaviest coins. The answer to the question is therefore True .