CSE 20: Discrete Mathematics for Computer Science. Prof. Miles Jones. Today s Topics: 3-cent and 5-cent coins. 1. Mathematical Induction Proof

Similar documents
1. Functions and set sizes 2. Infinite set sizes. ! Let X,Y be finite sets, f:x!y a function. ! Theorem: If f is injective then X Y.

Basic Computation. Chapter 2 Part 4 Case Study

CSE 20 DISCRETE MATH. Fall

The Chinese Remainder Theorem

Teacher s Notes. Problem of the Month: Courtney s Collection

Topics to be covered

Carmen s Core Concepts (Math 135)

Lecture 13 CS 1813 Discrete Mathematics. Induction Induction. CS 1813 Discrete Mathematics, Univ Oklahoma Copyright 2000 by Rex Page

Tangent: Boromean Rings. The Beer Can Game. Plan. A Take-Away Game. Mathematical Games I. Introduction to Impartial Combinatorial Games

Assignment 2. Due: Monday Oct. 15, :59pm

DVA325 Formal Languages, Automata and Models of Computation (FABER)

The Tilings of Deficient Squares by Ribbon L-Tetrominoes Are Diagonally Cracked

Notes for Recitation 3

Animation Demos. Shows time complexities on best, worst and average case.

1.6 Congruence Modulo m

Module 3 Greedy Strategy

The tenure game. The tenure game. Winning strategies for the tenure game. Winning condition for the tenure game

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

Animation Demos. Shows time complexities on best, worst and average case.

Worksheet Set - Mastering Numeration 1

ALGEBRA: Chapter I: QUESTION BANK

Pattern Avoidance in Unimodal and V-unimodal Permutations

Discrete Mathematics. Spring 2017

Other activities that can be used with these coin cards.

Cardinality revisited

Tutorial 1. (ii) There are finite many possible positions. (iii) The players take turns to make moves.

Subtraction games with expandable subtraction sets

17. Symmetries. Thus, the example above corresponds to the matrix: We shall now look at how permutations relate to trees.

A REMARK ON A PAPER OF LUCA AND WALSH 1. Zhao-Jun Li Department of Mathematics, Anhui Normal University, Wuhu, China. Min Tang 2.

Edge-disjoint tree representation of three tree degree sequences

Monotone Sequences & Cauchy Sequences Philippe B. Laval

Bishop Domination on a Hexagonal Chess Board

EXPLAINING THE SHAPE OF RSK

Discrete Mathematics & Mathematical Reasoning Multiplicative Inverses and Some Cryptography

Introduction to Modular Arithmetic

CS 202, section 2 Final Exam 13 December Pledge: Signature:

MC215: MATHEMATICAL REASONING AND DISCRETE STRUCTURES

Directed Towers of Hanoi

University of British Columbia. Math 312, Midterm, 6th of June 2017

Counting in Algorithms

Fermat s little theorem. RSA.

Senior Math Circles February 10, 2010 Game Theory II

CLASS NOTES. A mathematical proof is an argument which convinces other people that something is true.

SMT 2013 Advanced Topics Test Solutions February 2, 2013

Round and Round. - Circle Theorems 1: The Chord Theorem -

CSE 100: RED-BLACK TREES

NIM Games: Handout 1

Congruence properties of the binary partition function

Sec 5.1 The Basics of Counting

SOLUTIONS TO PROBLEM SET 5. Section 9.1

Number-Theoretic Algorithms

Massachusetts Institute of Technology 6.042J/18.062J, Spring 04: Mathematics for Computer Science April 16 Prof. Albert R. Meyer and Dr.

Number Theory - Divisibility Number Theory - Congruences. Number Theory. June 23, Number Theory

Power = 36² mod 99 Power = 9 5 a 5 = 0 x = 81 Power = 9² mod 99 Power = 81 6 a 6 = 1 x = 81 x 81 mod 99 x = 27 7 a 7 = 1 x = 27 x 27 mod 99 x = 36

Dollar Board $1.00. Copyright 2011 by KP Mathematics

Plan. Related courses. A Take-Away Game. Mathematical Games , (21-801) - Mathematical Games Look for it in Spring 11

Applications of Fermat s Little Theorem and Congruences

Response to Intervention. Grade 2

NOT QUITE NUMBER THEORY

The congruence relation has many similarities to equality. The following theorem says that congruence, like equality, is an equivalence relation.

THE INTEGERS. The sixth scene in a series of articles on elementary mathematics. written by Eugene Maier designed and illustrated by Tyson Smith

Math236 Discrete Maths with Applications

Greedy Flipping of Pancakes and Burnt Pancakes

Discrete Structures Lecture Permutations and Combinations

Reflections on the N + k Queens Problem

A tournament problem

Proofs of a Trigonometric Inequality

Chapter 6.1. Cycles in Permutations

Modular Arithmetic: refresher.

Chapter 1. Probability

Modular Arithmetic. claserken. July 2016

Lecture 8: Power Gain/ Matching Networks

Outline. Content The basics of counting The pigeonhole principle Reading Chapter 5 IRIS H.-R. JIANG

SOME MORE DECREASE AND CONQUER ALGORITHMS

Parallel Line Converse Theorems. Key Terms

Mistilings with Dominoes

Norman Do. A Mathemagical Card Trick. 1 Card Trick

Second Grade Mathematics Goals

CALCULATING SQUARE ROOTS BY HAND By James D. Nickel

Discrete Mathematics: Logic. Discrete Mathematics: Lecture 15: Counting

How to Become a Mathemagician: Mental Calculations and Math Magic

I can represent numbers using coins. Observations Daily checklist- Can students represent a number using coins on their white boards

Solution: This is sampling without repetition and order matters. Therefore

MATH 135 Algebra, Solutions to Assignment 7

11 Chain and Antichain Partitions

Introductory Probability

Countability. Jason Filippou UMCP. Jason Filippou UMCP) Countability / 12

Analyzing Games: Solutions

The Real Number System and Pythagorean Theorem Unit 9 Part B

Closed Almost Knight s Tours on 2D and 3D Chessboards

Module 3 Greedy Strategy

An Optimal Algorithm for a Strategy Game

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION MH1301 DISCRETE MATHEMATICS. Time Allowed: 2 hours

André and the Ballot Problem - History and a Generalization

Solutions of problems for grade R5

How Many Mates Can a Latin Square Have?

PRIMES STEP Plays Games

CSE 231 Spring 2013 Programming Project 03

Block 1 - Sets and Basic Combinatorics. Main Topics in Block 1:

Tilings with T and Skew Tetrominoes

Transcription:

2 Today s Topics: CSE 20: Discrete Mathematics for Computer Science Prof. Miles Jones 1. Mathematical Induction Proof! 3-cents and 5-cents example! Our first algorithm! 3 4 3-cent and 5-cent coins! We will prove the following theorem 1. Mathematical Induction Proof Examples, examples, examples! Theorem: For all prices p >= 8 cents, the price p can be paid using only 5-cent and 3-cent coins 1851-1889 1866-today

5 6 Basis step: Show the theorem holds for price p=. Basis step: Show the theorem holds for price p=. A. 0 cents B. 1 cent C. 2 cents D. 3 cents E. Other/none/more than one 7 8 A. Theorem is true for p=8. B. Theorem is true for some p>8. C. Theorem is true for some p 8. D. Theorem is true for some p>0. E. Theorem is true for all p>8.

9 10 theorem is true for some p 8. theorem is true for some p 8. A. Theorem is true for p=8. B. Theorem is true for some p>8. C. Theorem is true for p+1. D. Theorem is true for p+8. 11 12 theorem is true for some p 8. theorem is true for price p+1. theorem is true for some p 8. theorem is true for price p+1.???

13 14 3-cent and 5-cent coins!! Assume price p 8 can be paid using only 3- cent and 5-cent coins.! Need to prove that price p+1 can be paid using only 3-cent and 5-cent coins.! Main idea: reduce from price p+1 to price p. Making change! If we have 100 5-cent coins, and 100 3- cent coins (for a total of p = $8.00), how can we modify the number of 5-cent and 3-cent coins so that we can make the p+1 price (p+1 = $8.01)? A. 40 5-cent coins + 200 3-cent coins B. 39 5-cent coins + 202 3-cent coins C. 99 5-cent coins + 102 3-cent coins 15 16 Making change! If we have 100 5-cent coins, and 100 3- cent coins (for a total of p = $8.00), how can we modify the number of 5-cent and 3-cent coins so that we can make the p+1 price (p+1 = $8.01)? A. 40 5-cent coins + 200 3-cent coins B. 39 5-cent coins + 202 3-cent coins C. 99 5-cent coins + 102 3-cent coins Turning our modification scheme into a generic algorithm! If we have n 5-cent coins, and m 3-cent coins (for a total of p = 5n+3m), how can we modify the number of 5-cent and 3- cent coins so that we can make the p+1 price (p+1 = 5n+3m+1)? A. n+1 5-cent coins + m-2 3-cent coins B. n-1 5-cent coins + m+2 3-cent coins C. n+1 5-cent coins + m+2 3-cent coins D. No generic way

17 18 Turning our modification scheme into a generic algorithm! If we have n 5-cent coins, and m 3-cent coins (for a total of p = 5n+3m), how can we modify the number of 5-cent and 3- cent coins so that we can make the p+1 price (p+1 = 5n+3m+1)? A. n+1 5-cent coins + m-2 3-cent coins B. n-1 5-cent coins + m+2 3-cent coins C. n+1 5-cent coins + m+2 3-cent coins D. No generic way What if we don t have any 5- cent coins to subtract??! If we have 0 5-cent coins, and m 3-cent coins (for a total of p = 3m), how can we modify the number of 5-cent and 3-cent coins so that we can make the p+1 price (p+1 = 3m+1)? A. You can t B. You can [explain to your group how] 19 20 What if we don t have any 5- cent coins to subtract??! If we have 0 5-cent coins, and m 3-cent coins (for a total of p = 3m), how can we modify the number of 5-cent and 3-cent coins so that we can make the p+1 price (p +1 = 3m+1)?! Remove three 3-cent coins, add two 5-cent! So: two 5-cent coins, m-3 3-cent points, for a total of 2*5+3*(m-3)=3m+1=p+1 That algorithm relies on being able to subtract three 3-cent coins. What if we don t have that many? (only 1 or 2?) A. Uh-oh, our proof can not work as we ve done it so far B. That could never happen [explain why not] C. That could happen, and we need to make a 3 rd (or more) case(s) to handle it

21 22 Basis step: Show the theorem holds for p=8 (by example, e.g. p=3+5) the theorem holds for some p 8. the theorem holds for p+1. p 8. Assume that p=5n+3m where n,m 0 are integers. We need to show that p+1=5a+3b for integers a,b 0. Partition to cases: Case I: n 1. In this case, p+1=5*(n-1)+3*(m+2). Case II: m 3. In this case, p+1=5*(n+2)+3*(m-3). Case III: n=0 and m 2. Then p=5n+3m 6 which is a contradiction to p 8. We created an algorithm!! Our proof actually allows us to algorithmically find a way to pay p using 3- cent and 5-cent coins! Algorithm for price p:! start with x=8=3+5! For x=8...p, in each step adjust the number of coins according to the modification rules we ve constructed to maintain price x 23 24 Algorithm pseudo-code PayWithThreeCentsAndFiveCents: Input: price p 8. Output: integers n,m 0 so that p=5n+3m 1. Let x=8, n=1, m=1 (so that x=5n+3m). 2. While x<p: 3. Return (n,m) Algorithm pseudo-code PayWithThreeCentsAndFiveCents: Input: price p 8. Output: integers n,m 0 so that p=5n+3m 1. Let x=8, n=1, m=1 (so that x=5n+3m). 2. While x<p: 3. Return (n,m) Invariant: x=5n+3m Invariant: x=5n+3m We proved that n,m 0 in this process always; this is not immediate from the algorithm code

25 26 Algorithm run example! 8=! 9=! 10 =! 11=! 12 = x=8: n=1, m=1 While x<p: Invariant: x=5n+3m Algorithm properties! Theorem: Algorithm uses at most two nickels (i.e n 2)! Proof: by induction on p! Try to prove it yourself first! x=8: n=1, m=1 While x<p: Invariant: x=5n+3m 27 Algorithm properties! Theorem: Algorithm uses at most two nickels (i.e n 2). Proof: by induction on p Base case: p=8. Algorithm outputs n=m=1. Inductive hypothesis: p=5n+3m where n 2. WTS p+1=5a+3b where a 2. Proof by cases:! Case I: n 1. So p+1=5(n-1)+3(m+2) and a=n-1 2.! Case II: n=0. So p+1=5*2+3(m-3). a=2. In both cases p+1=5a+3b where a 2. QED x=8: n=1, m=1 While x<p: Invariant: x=5n+3m