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

Similar documents
CSE373: Data Structures and Algorithms Lecture 2: Proof by Nicki Dell Spring 2014

CSE373: Data Structures and Algorithms Lecture 2: Proof by & Algorithm Analysis. Lauren Milne Summer 2015

Discrete Mathematics. Spring 2017

CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis. Hunter Zahn Summer 2016

Mathematical Induction Assignments

Section 4.2: Mathematical Induction 1

CSE 311: Foundations of Computing. Lecture 14: Induction

Mathematical Induction. EECS 203: Discrete Mathematics Lecture 11 Spring

Climbing an Infinite Ladder

CSC 344 Algorithms and Complexity. Proof by Mathematical Induction

INDUCTION AND RECURSION. Lecture 7 - Ch. 4

Climbing an Infinite Ladder

Chapter 2 Section 2.1: Proofs Proof Techniques. CS 130 Discrete Structures

CS173 Strong Induction and Functions. Tandy Warnow

CS173 Lecture B, September 10, 2015

Mathematical Induction

n(n + 1). 2 . If n = 3, then 1+2+3=6= 3(3+1) . If n = 2, then = 3 = 2(2+1)

Fall 2015 Lecture 14: Modular congruences. cse 311: foundations of computing

THE ISLAMIC UNIVERSITY OF GAZA ENGINEERING FACULTY DEPARTMENT OF COMPUTER ENGINEERING DISCRETE MATHMATICS DISCUSSION ECOM Eng. Huda M.

Induction 1 = 1(1+1) = 2(2+1) = 3(3+1) 2

Mathematical Induction. Section 5.1

Math 38: Graph Theory Spring 2004 Dartmouth College. On Writing Proofs. 1 Introduction. 2 Finding A Solution

Conjectures and proof. Book page 24-30

Mathematical Induction

CISC-102 Fall 2017 Week 3. Principle of Mathematical Induction

e π i 1 = 0 Proofs and Mathematical Induction Carlos Moreno uwaterloo.ca EIT-4103 e x2 log k a+b a + b

Discrete Mathematics. Spring 2017

Any Wizard of Oz fans? Discrete Math Basics. Outline. Sets. Set Operations. Sets. Dorothy: How does one get to the Emerald City?

Proof by Mathematical Induction.

Mathematical Induction

Mathematical Induction Again

Quiz 3 Reminder and Midterm Results

Announcements. CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis. Today. Mathematical induction. Dan Grossman Spring 2010

Mathematical Induction Again

Induction. Announcements. Overview. Defining Functions. Sum of Squares. Closed-form expression for SQ(n) There have been some corrections to A1

Sum of Squares. Defining Functions. Closed-Form Expression for SQ(n)

CS 124 Math Review Section January 29, 2018

Solving with Absolute Value

How many hours would you estimate that you spent on this assignment?

Carmen s Core Concepts (Math 135)

Mathematical Induction. Defining Functions. Overview. Notation for recursive functions. Base case Sn(0) = 0 S(n) = S(n 1) + n for n > 0

Inference and Proofs (1.6 & 1.7)

Proof by Induction. Andreas Klappenecker

CS 220: Discrete Structures and their Applications. Mathematical Induction in zybooks

Prompt. Commentary. Mathematical Foci

CSC236 Week 3. Larry Zhang

Contents. Counting Methods and Induction

Mathematical Induction

A Brief Introduction to Proofs

2 Elementary number theory

Mathematical Induction

Math 231E, Lecture 25. Integral Test and Estimating Sums

PRINCIPLE OF MATHEMATICAL INDUCTION

Chapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015

Induction and Recursion

Proof Techniques (Review of Math 271)

MAC-CPTM Situations Project

Sequences & Mathematical Induction

Discrete Math, Spring Solutions to Problems V

Strong Mathematical Induction

The Sum n. Introduction. Proof I: By Induction. Caleb McWhorter

Math.3336: Discrete Mathematics. Mathematical Induction

CSCE 222 Discrete Structures for Computing. Proof by Induction. Dr. Hyunyoung Lee. !!!!!! Based on slides by Andreas Klappenecker

Introduction to Basic Proof Techniques Mathew A. Johnson

CSC236H Lecture 2. Ilir Dema. September 19, 2018

AQA Level 2 Further mathematics Further algebra. Section 4: Proof and sequences

Another Proof By Contradiction: 2 is Irrational

Time-bounded computations

With Question/Answer Animations

Note that r = 0 gives the simple principle of induction. Also it can be shown that the principle of strong induction follows from simple induction.

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February)

The Inductive Proof Template

At the start of the term, we saw the following formula for computing the sum of the first n integers:

MI 4 Mathematical Induction Name. Mathematical Induction

Mathematical Induction

Induction and recursion. Chapter 5

Recurrence Relations

CS 360, Winter Morphology of Proof: An introduction to rigorous proof techniques

Discrete Mathematics for CS Spring 2008 David Wagner Note 4

Lecture 6 : Induction DRAFT

EECS 1028 M: Discrete Mathematics for Engineers

MATH CSE20 Homework 5 Due Monday November 4

Problem Set 5 Solutions

CIS 2033 Lecture 5, Fall

Lecture 4: Probability, Proof Techniques, Method of Induction Lecturer: Lale Özkahya

Divisibility of Natural Numbers

Bayesian Updating with Discrete Priors Class 11, Jeremy Orloff and Jonathan Bloom

MATHEMATICAL INDUCTION

Proof Terminology. Technique #1: Direct Proof. Learning objectives. Proof Techniques (Rosen, Sections ) Direct Proof:

CVO103: Programming Languages. Lecture 2 Inductive Definitions (2)

CMSC250 Homework 9 Due: Wednesday, December 3, Question: Total Points: Score:

Sequences of Real Numbers

Mathematical Background

Dynamic Programming: Matrix chain multiplication (CLRS 15.2)

Matrix Multiplication

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018

Introduction to Induction (LAMC, 10/14/07)

Mathematical Reasoning Rules of Inference & Mathematical Induction. 1. Assign propositional variables to the component propositional argument.

Adam Blank Spring 2017 CSE 311. Foundations of Computing I

Transcription:

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 1. Show the statement is true for the first number. 2. Show that if the statement is true for any one number, this implies the statement is true for the next number. 3. If so, we can infer that the statement is true for all numbers. Spring 2016 2

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 3

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

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 5

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 6

Look for Patterns 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 1 3 6 10 15 21 Someone solved this a long time ago. You probably learned it once in high school. Spring 2016 7

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

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 9

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

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) n and k are just variables! Spring 2016 11

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 12

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 13

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 14

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 15

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 16

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 17

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 = (k+1)(k+2)/2 Spring 2016 18

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 = (k+1)(k+2)/2 Spring 2016 19

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 = (k+1)(k+2)/2 = (k+1)((k+1)+1)/2 Spring 2016 20

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 = (k+1)(k+2)/2 = (k+1)((k+1)+1)/2 Spring 2016 21

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

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

How to prove it P(n) = the sum of the first n powers of 2 (starting at 0) is 2 n -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 2 0, which equals 1 = 2 1-1. Inductive case: Assume the sum of the first k powers of 2 is 2 k -1 Show the sum of the first (k+1) powers of 2 is 2 k+1-1 Spring 2016 24

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

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 26

End of Inductive Proofs! Spring 2016 27

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 28