22C:19 Discrete Math Induction and Recursion Fall 2011 Sukumar Ghosh.

Slides:



Advertisements
Similar presentations
22C:19 Discrete Structures Induction and Recursion Spring 2014 Sukumar Ghosh.
Advertisements

22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
Recursive Definitions and Structural Induction
22C:19 Discrete Structures Trees Spring 2014 Sukumar Ghosh.
Induction and Recursion. Odd Powers Are Odd Fact: If m is odd and n is odd, then nm is odd. Proposition: for an odd number m, m k is odd for all non-negative.
Induction and recursion
Discrete Structures & Algorithms More on Methods of Proof / Mathematical Induction EECE 320 — UBC.
CSE115/ENGR160 Discrete Mathematics 04/03/12 Ming-Hsuan Yang UC Merced 1.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
CSE115/ENGR160 Discrete Mathematics 03/31/11
Chapter Mathematical Induction
Section Section Summary Recursive Algorithms Proving Recursive Algorithms Correct Recursion and Iteration (not yet included in overheads) Merge.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank. Modified By Mingwu Chen Induction.
Climbing an Infinite Ladder
Induction and recursion
Induction and recursion
Analysis of Recursive Algorithms October 29, 2014
Recursive Definitions and Structural Induction
MATH 224 – Discrete Mathematics
Induction and recursion
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 4 Induction and Recursion 歐亞書局.
Chapter 4: Induction and Recursion
CSE 311 Foundations of Computing I Lecture 16 Recursively Defined Sets and Structural Induction Spring
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
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,
Module #14: Recursion Rosen 5 th ed., §§ In this class, we will study recursion, one of the most important topics in computer science. In the last.
Induction and recursion
Mathematical Background and Linked Lists. 2 Iterative Algorithm for Sum Find the sum of the first n integers stored in an array v : sum (v[], n) temp_sum.
Chapter 5 With Question/Answer Animations. Section 5.1.
4.3 Recursive Definitions and Structural Induction Sometimes it is difficult to define an object explicitly. However, it may be easy to define this object.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Induction Proof. Well-ordering A set S is well ordered if every subset has a least element. [0, 1] is not well ordered since (0,1] has no least element.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
1 Recursive Definitions and Structural Induction CS 202 Epp section ??? Aaron Bloomfield.
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.
Recursive Algorithm (4.4) An algorithm is called recursive if it solves a problem by reducing it to an instance of the same problem with smaller input.
1 2/21/2016 MATH 224 – Discrete Mathematics Sequences and Sums A sequence of the form ar 0, ar 1, ar 2, ar 3, ar 4, …, ar n, is called a geometric sequence.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
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.
Chapter 5 Kenneth Rosen, Discrete Mathematics and its Applications, 7th edition, McGraw Hill Instructor: Longin Jan Latecki, Copyright.
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
Induction and Recursion CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
1 Recursive Definitions and Structural Induction CS/APMA 202 Rosen section 3.4 Aaron Bloomfield.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Mathematical Induction And Recursion Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
(Proof By) Induction Recursion
Chapter 4: Induction and Recursion
Induction and recursion
Recursive Algorithms Section 5.4.
MATH 224 – Discrete Mathematics
CS2210:0001Discrete Structures Induction and Recursion
Induction and recursion
Induction and Recursion
Lecture Outline for Recurrences
Induction and recursion
Applied Discrete Mathematics Week 9: Integer Properties
Chapter 4 Induction and Recursion
Rosen 5th ed., §§ ~18 slides, ~1 lecture
Mathematical Induction
Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011
Discrete Mathematics and its Applications
Induction and recursion
Induction and recursion
CSE 321 Discrete Structures
Discrete Mathematics and its Applications
Recursion.
Presentation transcript:

22C:19 Discrete Math Induction and Recursion Fall 2011 Sukumar Ghosh

What is mathematical induction? It is a method of proving that something holds. Suppose we have an infinite ladder, and we want to know if we can reach every step on this ladder. We know the following two things: 1.We can reach the base of the ladder 2.If we can reach a particular step, then we can reach the next step Can we conclude that we can reach every step of the ladder?

Understanding induction Suppose we want to prove that P(x) holds for all x

Proof structure

Example 1

Example continued

What did we show?

Example 2

Example continued

Example 3

Strong induction

Example

Proof using Mathematical Induction

Same Proof using Strong Induction

Errors in Induction Question: What is wrong here?

Errors in Induction Question: What is wrong here?

Recursion Recursion means defining something, such as a function, in terms of itself – For example, let f(x) = x! – We can define f(x) as f(x) = x * f(x-1)

Recursive definition Two parts of a recursive definition: Base case and a Recursive step.

Recursion example

Fibonacci sequence

Bad recursive definitions Why are these definitions bad?

More examples of recursion: defining strings

Structural induction A technique for proving a property of a recursively defined object. It is very much like an inductive proof, except that in the inductive step we try to show that if the statement holds for each of the element used to construct the new element, then the result holds for the new element too. Example. Prove that if T is a full binary tree, and h(T) is the height of the tree then the number of elements in the tree n(T) ≤ 2 h(T) See the textbook (pages ) for a solution.

Recursive Algorithm Example 1. Given a and n, compute a n procedure power (a : real number, n: non-negative integer) if n = 0 then power (a, n) := 1 else power (a, n) := a. power (a, n-1)

Recursive algorithms: Sorting Here is the recursive algorithm Merge sort. It merges two sorted Iists to produce a new sorted list

Mergesort The merge algorithm “merges” two sorted lists merged with will produce procedure mergesort (L = a 1, a 2, a 3, … a n ) if n > 0 then m:= n/2 L1 := a 1, a 2, a 3, … a m L2 := a m+1, a m+2, a m+3, … a n L := merge (mergesort(L1), mergesort(L2))

Example of Mergesort

Pros and Cons of Recursion While recursive definitions are easy to understand Iterative solutions for Fibonacci sequence are much faster (see )