CSS 342 DATA STRUCTURES, ALGORITHMS, AND DISCRETE MATHEMATICS I LECTURE 7. 150128.

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 Intro to Induction Supplementary Notes Prepared by Raymond Wong Presented by Raymond Wong.
TR1413: INTRO TO DISCRETE MATHEMATICS LECTURE 2: MATHEMATICAL INDUCTION.
CSE115/ENGR160 Discrete Mathematics 03/22/12 Ming-Hsuan Yang UC Merced 1.
CSS342: Induction1 Professor: Munehiro Fukuda. CSS342: Induction2 Today’s Topics Review of sequence and summations Mathematical induction Strong form.
Discrete Structures Chapter 5: Sequences, Mathematical Induction, and Recursion 5.2 Mathematical Induction I [Mathematical induction is] the standard proof.
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.
Induction and recursion
What it is? Why is it a legitimate proof method? How to use it?
ICS 253 Presents Mathematical Induction Sultan Almuhammadi muhamadi
Induction and recursion
CSS 342 DATA STRUCTURES, ALGORITHMS, AND DISCRETE MATHEMATICS I LECTURE CARRANO CARRANO CH ; CUSACK CH 8: OPTIONAL.
1 Recursion. 2 Basic Recursions Break a problem into smaller identical problems –Each recursive call solves an identical but smaller problem. a base caseStop.
Mathematical Induction. F(1) = 1; F(n+1) = F(n) + (2n+1) for n≥ F(n) n F(n) =n 2 for all n ≥ 1 Prove it!
Lecture 3.1: Mathematical Induction CS 250, Discrete Structures, Fall 2014 Nitesh Saxena Adopted from previous lectures by Cinda Heeren, Zeph Grunschlag.
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.
INDUCTION AND RECURSION. PRINCIPLE OF MATHEMATICAL INDUCTION To prove that P(n) is true for all positive integers n, where P(n) is a propositional function,
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 5: Recursion as a Problem-Solving Technique Data Abstraction.
CompSci 102 Discrete Math for Computer Science March 1, 2012 Prof. Rodger Slides modified from Rosen.
October 3, 2001CSE 373, Autumn Mathematical Background Exponents X A X B = X A+B X A / X B = X A-B (X A ) B = X AB X N +X N = 2X N 2 N +2 N = 2 N+1.
Inductive Proofs and Inductive Definitions Jim Skon.
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
Copyright © Zeph Grunschlag, Induction Zeph Grunschlag.
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,
CSS 342 DATA STRUCTURES, ALGORITHMS, AND DISCRETE MATHEMATICS I LECTURE CARRANO C++ INTERLUDE 2, CHAPT 4, 6.
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.
INDUCTION Lecture 22 CS2110 – Fall 2009 A well-known scientist (some say it was Bertrand Russell) once gave a public lecture on astronomy. He described.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Mathematical Induction Prudence Wong
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
Mathematical Induction EECS 203: Discrete Mathematics Lecture 11 Spring
9/27/2011 Lecture Mathematical Induction1 Lecture 3.1: Mathematical Induction* CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from.
Copyright © Zeph Grunschlag, Induction Zeph Grunschlag.
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.
Hubert Chan (Chapters 1.6, 1.7, 4.1)
CSE15 Discrete Mathematics 03/22/17
EECS 203: Discrete Mathematics
Induction and recursion
Methods of Proof A mathematical theorem is usually of the form pq
Hubert Chan (Chapters 1.6, 1.7, 4.1)
Proofs, Recursion and Analysis of Algorithms
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction
CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Notes 9.5 – Mathematical Induction
Induction and recursion
Follow me for a walk through...
CSE 373 Data Structures and Algorithms
What is this ? THIS IS A DOMINO.
Applied Discrete Mathematics Week 9: Integer Properties
Lecture 3.1: Mathematical Induction
Induction (Section 3.3).
Follow me for a walk through...
Mathematical Induction
Mathematical Induction
Follow me for a walk through...
Copyright © Cengage Learning. All rights reserved.
Lecture 3.1: Mathematical Induction
Data Structures & Programming
Presentation transcript:

CSS 342 DATA STRUCTURES, ALGORITHMS, AND DISCRETE MATHEMATICS I LECTURE

Agenda Recursion Induction Quiz

CSS342: RECURSION3 Backtrack: 8 queens problem ◦Place 8 queens on a 8 * 8 chessboard so that no queen can attack any other queen.

*from Carranno Place one queen in one column at a time. Backtrack when problems occur.

8 Queens: Pseudo-code bool addQueen( bool t[SIZE][SIZE], int col ) { if ( col >= SIZE ) return true; // all cols have been examined for ( int row = 0; row < SIZE; row++ ) { if ( safeLocation( t, row, col ) ) { // this row may be a candidate t[row][col] = true; // place a new queen; if ( addQueen( t, col + 1 ) ) return true; // all the following cols were filled else t[row][col] = false; // A wrong position. Try the next row } return false; // all rows examined, but no candidates }

Induction Axiom: The principle of mathematical induction A property P(n) that involves an integer n is true for all n ≥ 0 if the following are true: 1.P(0) is true. 2.If P(k) is true for any k ≥ 0, then P(k+1) is true.

Intuitive Reasoning about proofs by induction Imagine a monkey climbing a ladder Teach how to go from one rung to another rung: K to K+1 Teach how to get onto Rung 1 Imagine a set of dominoes The k numbered domino knocks over the k+1 domino Knock over the first domino Syllabus updates: Cusack book optional for induction, but helpful

Some history* *from our good friends at Wickapedia

Proof by Induction for x n Write a recursive function which calculates x n Prove the correctness of the recursive solution using inductoin int pow(int x, int n) { if (n == 0) return 1; else return x * pow(x, n-1); }

Proof by Induction for x n 1.Basis: When n = 0, pow(x, 0) = 1. x 0 = 1. The recursive function is correct. 2.Inductive hypothesis: When n = k, assume that pow(x, k) is correct, i.e., x k. 3.Inductive step: Show the pow(x, k+1) is correct. pow(x, k+1) = x * pow(x, k) By the inductive hypothesis, pow(x, k) returns the value x k. Thus, pow(x, k+1)= x * x k = x k+1 4.If pow(x, k) is correct, pow(x, k+1) is correct. Therefore, by the principle of mathematical induction, pow(x, n) is correct for any n ≥ 1.

Quiz