1 / 20

Fake Coin

Fake Coin. Fake coin detection Introduction.

nishi
Download Presentation

Fake Coin

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fake Coin

  2. Fake coin detection Introduction • Suppose we are given a number of coins, each identical, at most one isfake and the others are genuine.All genuine coins have the same weight,And the fake coin has a different weight from the genuine coins.How can we use a pair of scales to detect the fake coin?

  3. Problem formulation • There are 3 possible outcomes when a pair of scales is used;The scales may tip left or right or balance.With n comparisons, there are 3^n different outcomes.Given m coins, there are 1+2m possible outcomes.1 possibility is all coins are genuine.There are 2 ways each of the m coins can be fake.1+2m = 3^nIf the number of coins m, is greater than ½ (3^n -1), it is impossibleto find a fake coin if it exists.

  4. Conjecture • Given ½ (3^n -1) coins (of which at most one is fake), it is possibleto identify the fake coin, if it exists, using at most n comparisons.n=0, the conjecture is truen=1, the conjecture is false!! If we have one coin, how can we tell ifit is genuine or not, we have nothing to compare it with.Similar if we have two coins.

  5. Modify conjecture. Additional coin • Let us modify our conjecture,Assume we have an additional reference coin, that we know to be genuine.The problem is to construct an algorithm, which will identify the fakecoin (if it exists), or determine all the coins are genuine.

  6. 6.7.2 Problem solution basis • With 0 comparisons, we know all the coins in a collection of ½ (3^0-1)are genuine,The base case, n=0 is solved.

  7. Inductive step • Let c.n denote ½ (3^n – 1).By induction, we may assume that a fake coin (if it exists), can befound among c.n coins using a maximum of n comparisons.We have to show how to find a fake coin among c(n+1) coins using atmost n+1 comparisons.

  8. First Comparison 1 • To be able to gain any information from a comparison,The number of coins on the left and right scales must be the same.If the scales balance, then none of the coins on the scales is fake.We can then discard these coins, and look at the coins on the table.Hence c.n coins must remain on the table as c.n is the maximum numberof coins among which a fake coin could be detected with n comparisons.

  9. First Comparison 2 • This also tells us how many coins to put on the scalesi.e. the difference between c(n+1) and c.nc(n+1) = 3c.n+1 (by arithmetic)so, c.(n+1)-c.n = 3^nThis is an odd number, which we cannot put on the scales,However we can make this even by using the reference coin(which we have in addition to the c(n+1) coins).We conclude that in the first comparison, c.n+1 coins should be put oneach side of the scales.

  10. 3 possibilities. • what to do after the first comparison.There are 3 possibilities.if the scales balance, the fake coin is among the c.n coins left on the table.If the scales tip to one side, we are still left with 3^n coins, whichis greater than c.n,And we are unable to apply the inductive hypothesis to this number of coins.

  11. What do we learn. • The comprison does tell us something about the coins on the scales.If the scales tip to one side,We know that all the coins on that side are possibly heavier than a genuine coinAnd all the coins on the other side are possibly heavier.By possibly lighter, we mean genuine, or fake and lighter.By possibly heavier, we mean genuine, or fake and heavier.After the comparison, we can mark all of the coins on the scales oneway or the other.

  12. Marked coin problem. • In this way, the problem we started with has been reduced to adifferent problem.The new problem is this.Suppose a number of coins are supplied, each marked "possibly light"or "possibly heavy".Exactly one coin is fake. The rest are genuine.Construct an algorithm which will determine, with at most ncomparisons, the fake coin among 3^n coins.

  13. Base case • The base case is easy.n=0, there is one coin, which must be fake.There are 0 comparisons needed to establish this fact.

  14. Inductive step. • Some coins are put on the left pan, some on the right pan, and some onthe table.We are supplied with 3^(n+1) marked coins.The coins must be divided equally 3^n on the left, 3^n on the right,and 3^n on the table.

  15. Marking of the coins • We need to determine how to place the coins accoriding to their markings.Suppose L1 possibly light coins are placed on the left, and L2 on the right.Siilarly H1 possibly heavy coins on the left, and H2 on the rightTo learn anything from a comparison, the numbers of coins on left andright must be same.i.e. L1+H1 = L2 +H2 and should equal 3^n

  16. Comparison p103 • If the scales tip to the left, all the coins on the left are possiblyheavy and all the coins on the right are possibly light.Combined with the markings, we conclude the L1 possibly light coins onthe left and the H2 possibly heavy coins on the right are genuine(since possibly heavy and possibly light means genuine).The converse is true

  17. Apply the inductive hypothesis • We require the number of coins not eliminated equal 3^n.This implies that H1+L2=L1+H2=3^nTogether with L1+H1= L2+H2 we inferL1 = L2 and H1 = H2We must arrange the coins so that each scale contains equal numbers ofcoins of the same kind.

  18. The complete solution to the marked coin problem • The fake coin is found from 3^(n+1) marked coins by placing 3^n coinson each scale such that there is an equal number of possibly lightcoins on each scale.If the scales balance, all of the coins on the scale are genuine,procede with the coins on the table.If the scales tip to the left, the coins on the table are genuine.So too are the possibly light coins on the left and the possibly heavycoins on the right.Proceed with the possibly heavy coins on the left scale and thepossibly light coins on the right scale.

  19. The complete solution to the unmarked coin problem • Divide the coins into 3 groups. ½ (3^n-1), ½ (3^n-1)+1, ½ (3^n-1),Place the first group on the left with the genuine coin,Place the second group on the right and the third group on the table.

  20.  3 Outcomes • If the scales balance, all of the coins on the scales are gienuine,Apply the solution to the unmarked coin problem (inductively) to thecoins on the table.If the scales tip to the left, the coins on the table are genuine.Mark all the coins on the left (with the exception of the genuine one)as possibly heavy.Mark all the coins on the right as possibly light.Apply the solution to the marked coin problem to the 3^n marked coins.(similarly if tip to the right).

More Related