CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction

Slides:



Advertisements
Similar presentations
1 Mathematical Induction. 2 Mathematical Induction: Example  Show that any postage of ≥ 8¢ can be obtained using 3¢ and 5¢ stamps.  First check for.
Advertisements

Induction and recursion
1 Mathematical Induction. 2 Mathematical Induction: Example  Show that any postage of ≥ 8¢ can be obtained using 3¢ and 5¢ stamps.  First check for.
Discrete Structures Chapter 5: Sequences, Mathematical Induction, and Recursion 5.2 Mathematical Induction I [Mathematical induction is] the standard proof.
Chapter 10 Sequences, Induction, and Probability Copyright © 2014, 2010, 2007 Pearson Education, Inc Mathematical Induction.
Copyright © Cengage Learning. All rights reserved.
CSE115/ENGR160 Discrete Mathematics 03/29/11 Ming-Hsuan Yang UC Merced 1.
1 Strong Mathematical Induction. Principle of Strong Mathematical Induction Let P(n) be a predicate defined for integers n; a and b be fixed integers.
1 Mathematical Induction. 2 Mathematical Induction: Example  Show that any postage of ≥ 8¢ can be obtained using 3¢ and 5¢ stamps.  First check for.
Induction and Recursion by: Mohsin tahir (GL) Numan-ul-haq Waqas akram Rao arslan Ali asghar.
MATHEMATICS INDUCTION AND BINOM THEOREM By : IRA KURNIAWATI, S.Si, M.Pd.
Algorithm Design and Analysis (ADA)
Sequences and Series (T) Students will know the form of an Arithmetic sequence.  Arithmetic Sequence: There exists a common difference (d) between each.
Lecture 9. Arithmetic and geometric series and mathematical induction
Induction and recursion
RMIT University; Taylor's College1 Lecture 6  To apply the Principle of Mathematical Induction  To solve the Towers of Hanoi puzzle  To define a recurrence.
Chapter 6 Mathematical Induction
College Algebra Fifth Edition James Stewart Lothar Redlin Saleem Watson.
CSNB143 – Discrete Structure Topic 5 – Induction Part I.
CSE373: Data Structures and Algorithms Lecture 2b: Proof by Induction and Powers of Two Nicki Dell Spring 2014.
CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction & Algorithm Analysis Lauren Milne Summer 2015.
9.4 Mathematical Induction
Mathematical Induction Digital Lesson. Copyright © by Houghton Mifflin Company, Inc. All rights reserved. 2 Mathematical induction is a legitimate method.
Section 3.3: Mathematical Induction Mathematical induction is a proof technique that can be used to prove theorems of the form:  n  Z +,P(n) We have.
CompSci 102 Discrete Math for Computer Science March 1, 2012 Prof. Rodger Slides modified from Rosen.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction Linda Shapiro Winter 2015.
INDUCTION Slides of Ken Birman, Cornell University.
Mathematical Induction
Chapter 5. Section 5.1 Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Mathematical Induction Thinking Skill: Develop Confidence in Reason Warm Up: Find the k+1 term (P k+1 ) 1) 2)
Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach a particular.
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
Mathematical Induction EECS 203: Discrete Mathematics Lecture 11 Spring
Mathematical Induction I Lecture 19 Section 4.2 Mon, Feb 14, 2005.
3.3 Mathematical Induction 1 Follow me for a walk through...
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
Mathematical Induction. The Principle of Mathematical Induction Let S n be a statement involving the positive integer n. If 1.S 1 is true, and 2.the truth.
11.7 – Proof by Mathematical Induction
CSE15 Discrete Mathematics 03/22/17
Advanced Algorithms Analysis and Design
CSE 311 Foundations of Computing I
Chapter 3 The Real Numbers.
Induction and recursion
CSE 311: Foundations of Computing
Methods of Proof A mathematical theorem is usually of the form pq
Proofs, Recursion and Analysis of Algorithms
CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction
Notes 9.5 – Mathematical Induction
Induction and recursion
CSE 311: Foundations of Computing
Exercise Use mathematical induction to prove the following formula.
Follow me for a walk through...
CSE 373 Data Structures and Algorithms
Section 2.1 Proof Techniques Introduce proof techniques:   o        Exhaustive Proof: to prove all possible cases, Only if it is about a.
Lesson 11 – Proof by induction
Applied Discrete Mathematics Week 9: Integer Properties
Mathematical Induction
Follow me for a walk through...
Advanced Analysis of Algorithms
Chapter 11: Further Topics in Algebra
Mathematical Induction
Mathematical Induction
Mathematical Induction
Follow me for a walk through...
Copyright © Cengage Learning. All rights reserved.
11.4 Mathematical Induction
Chapter 1 Automata CE year IV.
Presentation transcript:

CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction Linda Shapiro Spring 2016

Background on Induction Type of mathematical proof Typically used to establish a given statement for all natural numbers (e.g. integers > 0) Proof is a sequence of deductive steps Show the statement is true for the first number. Show that if the statement is true for any one number, this implies the statement is true for the next number. If so, we can infer that the statement is true for all numbers. Spring 2016

Think about climbing a ladder 1. Show you can get to the first rung (base case) 2. Show you can get between rungs (inductive step) 3. Now you can climb forever. Spring 2016

Why you should care Induction turns out to be a useful technique AVL trees Heaps Graph algorithms Can also prove things like 3n > n3 for n ≥ 4 Exposure to rigorous thinking Spring 2016

Example problem Find the sum of the integers from 1 to n 1 + 2 + 3 + 4 + … + (n-1) + n For any n ≥ 1 Could use brute force, but would be slow There’s probably a clever shortcut Spring 2016

Finding the formula Shortcut will be some formula involving n Compare examples and look for patterns Not something I will ask you to do! Start with n = 10: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = ??? Large enough to be a pain to add up Worthwhile to find shortcut Spring 2016

Look for Patterns n = 1: 1 n = 2: 1 + 2 n = 3: 1 + 2 + 3 6 10 15 21 n = 1: 1 n = 2: 1 + 2 n = 3: 1 + 2 + 3 n = 4: 1 + 2 + 3 + 4 n = 5: 1 + 2 + 3 + 4 + 5 n = 6: 1 + 2 + 3 + 4 + 5 + 6 Someone solved this a long time ago. You probably learned it once in high school. Spring 2016

The general form We want something for any n ≥ 1 Spring 2016

Are we done? The pattern seems pretty clear Is there any reason to think it changes? We want something for any n ≥ 1 A mathematical approach is skeptical We must prove the formula works in all cases A rigorous proof Spring 2016

Proof by Induction Prove the formula works for all cases. Induction proofs have four components: The thing you want to prove, e.g., sum of integers from 1 to n = n(n+1)/2 The base case (usually "let n = 1"), The assumption step (“assume true for n = k") The induction step (“now let n = k + 1"). n and k are just variables! Spring 2016

Proof by induction P(n) = sum of integers from 1 to n We need to do Base case Assumption Induction step n and k are just variables! prove for P(1) assume for P(k) show for P(k+1) Spring 2016

Proof by induction P(n) = sum of integers from 1 to n We need to do Base case Assumption Induction step prove for P(1) assume for P(k) show for P(k+1) 1 2 3 4 5 6… Spring 2016

✓ Proof by induction What we are trying to prove: P(n) = n(n+1)/2 Base case P(1) = 1 1(1+1)/2 = 1(2)/2 = 1(1) = 1 ✓ Spring 2016

Proof by induction What we are trying to prove: P(n) = n(n+1)/2 Assume true for k: P(k) = k(k+1)/2 Induction step: Now consider P(k+1) = 1 + 2 + … + k + (k+1) Spring 2016

Proof by induction What we are trying to prove: P(n) = n(n+1)/2 Assume true for k: P(k) = k(k+1)/2 Induction step: Now consider P(k+1) = 1 + 2 + … + k + (k+1) = k(k+1)/2 + (k+1) Spring 2016

Proof by induction What we are trying to prove: P(n) = n(n+1)/2 Assume true for k: P(k) = k(k+1)/2 Induction step: Now consider P(k+1) = 1 + 2 + … + k + (k+1) = k(k+1)/2 + (k+1) = k(k+1)/2 + 2(k+1)/2 Spring 2016

Proof by induction What we are trying to prove: P(n) = n(n+1)/2 Assume true for k: P(k) = k(k+1)/2 Induction step: Now consider P(k+1) = 1 + 2 + … + k + (k+1) = k(k+1)/2 + (k+1) = k(k+1)/2 + 2(k+1)/2 = (k(k+1) + 2(k+1))/2 Spring 2016

Proof by induction What we are trying to prove: P(n) = n(n+1)/2 Assume true for k: P(k) = k(k+1)/2 Induction step: Now consider P(k+1) = 1 + 2 + … + k + (k+1) = k(k+1)/2 + (k+1) = k(k+1)/2 + 2(k+1)/2 = (k+1)(k+2)/2 = (k(k+1) + 2(k+1))/2 Spring 2016

Proof by induction What we are trying to prove: P(n) = n(n+1)/2 Assume true for k: P(k) = k(k+1)/2 Induction step: Now consider P(k+1) = 1 + 2 + … + k + (k+1) = k(k+1)/2 + (k+1) = k(k+1)/2 + 2(k+1)/2 = (k+1)(k+2)/2 = (k(k+1) + 2(k+1))/2 Spring 2016

✓ Proof by induction What we are trying to prove: P(n) = n(n+1)/2 Assume true for k: P(k) = k(k+1)/2 Induction step: Now consider P(k+1) = 1 + 2 + … + k + (k+1) = k(k+1)/2 + (k+1) = k(k+1)/2 + 2(k+1)/2 = (k+1)(k+2)/2 ✓ = (k(k+1) + 2(k+1))/2 = (k+1)((k+1)+1)/2 Spring 2016

✓ Proof by induction What we are trying to prove: P(n) = n(n+1)/2 Assume true for k: P(k) = k(k+1)/2 Induction step: Now consider P(k+1) = 1 + 2 + … + k + (k+1) = k(k+1)/2 + (k+1) = k(k+1)/2 + 2(k+1)/2 = (k+1)(k+2)/2 ✓ = (k(k+1) + 2(k+1))/2 = (k+1)((k+1)+1)/2 Spring 2016

We’re done! P(n) = sum of integers from 1 to n We have shown Base case Assumption Induction step Success: we have proved that P(n) is true for any integer n ≥ 1  proved for P(1) assumed for P(k) proved for P(k+1) Spring 2016

Another one to try What is the sum of the first n powers of 2? k = 1: 20 = 1 k = 2: 20 + 21 = 1 + 2 = 3 k = 3: 20 + 21 + 22 = 1 + 2 + 4 = 7 k = 4: 20 + 21 + 22 + 23 = 1 + 2 + 4 + 8 = 15 For general n, the sum is 2n - 1 Spring 2016

How to prove it P(n) = “the sum of the first n powers of 2 (starting at 0) is 2n-1” Theorem: P(n) holds for all n ≥ 1 Proof: By induction on n Base case: n=1. Sum of first 1 power of 2 is 20 , which equals 1 = 21 - 1. Inductive case: Assume the sum of the first k powers of 2 is 2k-1 Show the sum of the first (k+1) powers of 2 is 2k+1-1 Spring 2016

How to prove it The sum of the first k+1 powers of 2 is 20 + 21 + 22 + ... + 2(k-1) + 2k = 2(2k) -1 = 2k+1 - 1 sum of the first k powers of 2 by inductive hypothesis = 2k - 1 + 2k Spring 2016

Problem for you to work: Prove: For n ≥ 1, 1×2 + 2×3 + 3×4 + ... + (n)(n+1) = (n)(n+1)(n+2)/3 Basis: n = 1 Assume true for k: Induction step: Spring 2016

End of Inductive Proofs! Spring 2016

Conclusion Mathematical induction is a technique for proving something is true for all integers starting from a small one, usually 0 or 1. A proof consists of three parts: 1. Prove it for the base case. 2. Assume it for some integer k. 3. With that assumption, show it holds for k+1 It can be used for complexity and correctness analyses. Spring 2016