Fake coin detection. Fake coins Suppose we have a number of coins, at most one is fake (i.e. either one is fake or none is fake). You have a pair of scales.

Slides:



Advertisements
Similar presentations
Weighing Created by Inna Shapiro ©2007 Problem 1 Judy has 3 old coins. She knows that one coin is fake and is heavier than the other two. How can she.
Advertisements

AE1APS Algorithmic Problem Solving John Drake
Today’s topics Decision Trees Reading: Sections 9.1 CompSci 102.
OR Simplex method (algebraic interpretation) Add slack variables( 여유변수 ) to each constraint to convert them to equations. (We may refer it as.
Outline. Theorem For the two processor network, Bit C(Leader) = Bit C(MaxF) = 2[log 2 ((M + 2)/3.5)] and Bit C t (Leader) = Bit C t (MaxF) = 2[log 2 ((M.
Induction.
Discrete Structure Li Tak Sing( 李德成 ) Lectures
Solving Quadratic Equations using Factoring.  has the form: ax 2 + bx + c = 0 If necessary, we will need to rearrange into this form before we solve!
Solving Equations with the Variable on Both Sides Objectives: to solve equations with the variable on both sides.
Let’s solve the equation: We shall use a scale to represent our equation. The variable x will be replaced with and the numbers will be represented with.
Copyright © Cengage Learning. All rights reserved.
DAST 2005 Week 4 – Some Helpful Material Randomized Quick Sort & Lower bound & General remarks…
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Trees.
LIAL HORNSBY SCHNEIDER
§ 10.5 Systems of Nonlinear Equations in Two Variables.
College Algebra Exam 2 Material.
Linear Inequalities in Two Variables
Systems of Linear Equations
1 MA 1128: Lecture 09 – 6/08/15 Solving Systems of Linear Equations.
LINEAR EQUATION IN TWO VARIABLES. System of equations or simultaneous equations – System of equations or simultaneous equations – A pair of linear equations.
Systems of Equations and Inequalities
Solving Algebraic Equations
estimate and find solutions to application problems involving proportional relationships such as similarity, scaling, unit costs, and related measurement.
Properties of Graphs of Quadratic Functions
12 Feb 2009MATH 1314 College Algebra Ch Quadratic Functions Objectives –Recognize characteristics of parabolas –Graph parabolas –Determine a quadratic.
3.2 Solving Systems of Equations Algebraically Substitution Method Elimination Method.
Copyright © Cengage Learning. All rights reserved.
Solving Using Matrices By Helen Chin Kitty Luo Anita La.
APS various problems. Not all bit-strings are compressible. If we have a bit string length n, sometimes we can compress it to a shorter bit string! Here.
Introduction to Algebra
Copyright © 2014, 2010 Pearson Education, Inc. Chapter 2 Polynomials and Rational Functions Copyright © 2014, 2010 Pearson Education, Inc.
The Selection Problem. 2 Median and Order Statistics In this section, we will study algorithms for finding the i th smallest element in a set of n elements.
Definition A mathematical sentence, that shows that two expressions, either numerical or algebraic, are equivalent. Like a balance. Characteristics Isolate.
Linear Inequalities and Linear Programming Chapter 5 Dr.Hayk Melikyan Department of Mathematics and CS
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
Solving Addition and Subtraction Equations Which word do you think “Equation” has a connection to?
 A quadratic inequality is an inequality in the form ax 2 +bx+c >,
Tom, Dick, Harry and the Gorilla An Investigation.
Solving and using number lines Inequalities. Inequalities and Equalities What’s the difference? What are the answers?
Solve Inequalities 1 © Evergreen Public Schools 7/28/10.
Solving Quadratic Equations Quadratic Equations: Think of other examples?
Solving Compound Inequalities. Solving Absolute Value Inequalities Example 1 This is a compound inequality. It is already set up to start solving the.
Puzzle of Week 1 You have 2 identical straight pieces of rope. Each takes 1 hour to burn if you light it from 1 side (it doesn’t matter which one). Show.
MTH Algebra THE ADDITION PROPERTY OF EQUALITY CHAPTER 2 SECTION 2.
Lesson 1 Contents Example 1Graph a Quadratic Function Example 2Axis of Symmetry, y-Intercept, and Vertex Example 3Maximum or Minimum Value Example 4Find.
Ultimatealgebra.com. WELCOME TO THIS CHAPTER 12 part 1 WE WOULD BE LEARNING ABOUT INEQUALITIES PLEASE MASTER THESE BEFORE YOU MOVE TO THE NEXT PART BECAUSE.
Solving Addition and Subtraction Equations Lesson 6-2 Page 225.
Quadratic Inequalities You can solve a quadratic inequality algebraically by factoring. Just like solving a quadratic equality we set it = to 0. we move.
The Pigeonhole Principle Alan Kaylor Cline. The Pigeonhole Principle Statement Children’s Version: “If k > n, you can’t stuff k pigeons in n holes without.
Linear Inequalities in Two Variables Write each inequality in interval notation and graph the interval. EXAMPLE 1 Graphing Intervals Written in Interval.
Logic Development Problems. Puzzle #1 You have a measurement scale where on both sides you can put some balls for weighing. You have a set of eight balls,
Solving equations with variable on both sides Part 1.
Lesson 8.1. » A statement where two mathematical expressions are. » Think of an equation as a balance scale or teeter-totter. The left side must always.
Modified Bessel Equations 홍성민. General Bessel Equation of order n: (1) The general solution of Eq.(1) Let’s consider the solutions of the 4.
Solving Addition and Subtraction Equations An equation is a mathematical sentence that contains an equal sign.
Solving Systems of Equation Using Elimination. Another method for solving systems of equations Eliminate one of the variables by adding the two equations.
1 Section 5.1 Analyzing Algorithms Let P be a problem and A an algorithm to solve P. The running time of A can be analyzed by counting the number of certain.
Solving Systems of Equations
Introduction Situations in the real world often determine the types of values we would expect as answers to equations and inequalities. When an inequality.
one-step addition/subtraction equations
Introduction Situations in the real world often determine the types of values we would expect as answers to equations and inequalities. When an inequality.
Solving Linear Systems
a + 2 = 6 What does this represent? 2 a
Introduction Situations in the real world often determine the types of values we would expect as answers to equations and inequalities. When an inequality.
The Selection Problem.
Copyright © Cengage Learning. All rights reserved.
The Pigeonhole Principle
Presentation transcript:

Fake coin detection

Fake coins Suppose we have a number of coins, at most one is fake (i.e. either one is fake or none is fake). You have a pair of scales (a balance), and you want to find the fake coin, if it exists, with the minimum number of comparisons. Coins can be placed on the left or right of the scales or not (i.e. we place the remaining coins on the table).

problem solving process. What is important here is the problem solving process. We first find that we cannot solve the problem as it is stated (if we only have one coin, what does it mean to say if it is genuine or fake). We then go on to solve a second problem (which we will call the marked coin problem), and this will help us to solve the original problem (which we can call the unmarked coin problem).

2m+1 possibilities Suppose that there are m coins, and one is heavy (then there are m possibilities). If one coin is heavier or lighter, then there are 2m possibilities. And if there is not a fake coin then there are 2m+1 possibilities.

1+2m≥3^{n}. When we make a comparison with the scales there are three possibilities, tip left, right or balance. With n comparisons there are 3^{n} different possibilities, giving an upper bound on the number of situations we can distinguish. Therefore 1+2m≥3^{n}.

c(n) The most coins we can distinguish between is where there is equality. By rearranging with a little algebra m=1/2 (3^{n}-1). Let us call this value c(n) = 1/2 (3^{n}-1).

how this function grows We can see how this function grows for the first few values. c(0)=0, c(1)=1, c(2)=4, c=(13).

Two coins??? The base case is trivial, with no coins we make no comparisons, and the problem is solved. But with one coin we cannot say if it is genuine or fake as we have nothing to compare it with. Therefore the question does not make sense, so let us assume that we have a reference coin which is genuine.

The induction step The induction step is as follows. We assume that if the fake coin exists among a set of c(n) coins, it can be found with at most n comparisons. We have to show (build on this assumption) how to find the fake coin among c(n+1) coins, with at most n+1 comparisons.

If the scales balance, then the fake coin must be on the table (i.e. the coin is not on the scales). Therefore we can examine the coins on the table. We have made one comparison, therefore we must be left with no more than c(n) coins on the table. As we know how many coins are not on the scales, we know how many coins are on the scales.

c(n+1) c(n+1) = 3.c(n)+1. (by basic algebra) so c(n+1)-c(n) = 2c(n)+1=3^{n}.

the additional reference This number is odd (2c(n) is even), 3^{n} is odd. Therefore we cannot split this number in two and put half on left and right of the scales. But we have the additional reference coin, therefore we put c(n)+1 coins on one side and c(n)+reference coin on the other side of the scales.

we cannot apply the inductive hypothesis. If the scales tip, we can eliminate the coins on the table (i.e. not on the scales), but then we are left with 2c(n)+1 coins!!! And this is greater than c(n), so we cannot apply the inductive hypothesis.

possibly heavier and possibly lighter. But this comparison not only tells us that the fake coin is among the coins on the scales, but it also tells us which coins are possibly heavier and possibly lighter. This is important information and should be utilized. Let us now move onto a new problem where the coins are marked either possibly heavier or lighter.

marked coin problem Here is the marked coin problem. We are supplied with a number of coins, each marked possible heavy (H) or possibly light (L), and exactly one coin is fake (note that this is different to the original problem above, and is a sub-problem).

L1+H1=L2+H2 Suppose L1 coins are placed on the left and H1 coins are placed on the left. Suppose L2 coins are placed on the right and H2 coins are placed on the right. The number of coins on the left and right must be equal (in order to make any meaningful comparison). L1+H1=L2+H2 (=3^{n}).

L1+H2=L2+H1 If the scales tip (e.g. to the left), then the L1 coins and H2 coins must be genuine (and vice versa). In order to apply the inductive hypothesis, this number must be equal to 3^{n}. This means L1+H2=L2+H1.

L1=L2 and H1=H2 These two equations imply that L1=L2 and H1=H2, in other words, each side must contain the same number of coins of the same type. This is another example of symmetry. This can always be achieved as, given three coins at least two must be of the same type. We can now describe the solution to the marked coin problem and then the solution to the unmarked coin problem.

marked coin problem The solution to the marked coin problem is as follows. Given 3^{n+1} marked coins, place 3^{n} on each side of the scale so that there are the same number of each type of coin on each side. If the scales balance proceed with the coins on the table (i.e. not on the scale). Else, if the scales tip to the left proceed with the possibly heavy coins on the left and possibly light coins n the right (vice versa if tip right).

unmarked coins problem The solution to the unmarked coins problem is as follows. Divide the coins into 3 piles (3^{n}- 1)/2 + reference coin (put on the left), (3^{n}- 1)/2 +1 (put on the right), and (3^{n}-1)/2 (to leave on the table). If the scales balance, proceed with the coins on the table with the unmarked solution. If the scales tip, mark all of the coins as either possibly heavy or possibly light, and proceed with the marked coin solution.