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

Slides:



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

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.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
CSE115/ENGR160 Discrete Mathematics 03/31/11
Lecture Recursive Definitions. Fractals fractals are examples of images where the same elements is being recursively.
Chapter Mathematical Induction
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank. Modified By Mingwu Chen Induction.
Induction and recursion
22C:19 Discrete Math Induction and Recursion Fall 2011 Sukumar Ghosh.
Induction and recursion
Recursive Definitions and Structural Induction
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
Divide-and-Conquer 7 2  9 4   2   4   7
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.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Induction and recursion
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.
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.
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.
1 Chapter 8 Recursion. 2 Recursive Function Call a recursion function is a function that either directly or indirectly makes a call to itself. but we.
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.
Recursive Definitions and Structural Induction ICS 6D Sandy Irani.
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
MATH 224 – Discrete Mathematics
Induction and Recursion Chapter 5
Divide-and-Conquer 6/30/2018 9:16 AM
CS2210:0001Discrete Structures Induction and Recursion
Induction and recursion
Induction and Recursion
Recursively Defined Functions
Discrete Structures for Computer Science
Lecture Outline for Recurrences
Induction and recursion
Divide-and-Conquer 7 2  9 4   2   4   7
Applied Discrete Mathematics Week 9: Integer Properties
Chapter 4 Induction and Recursion
Divide-and-Conquer 7 2  9 4   2   4   7
Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011
Divide-and-Conquer 7 2  9 4   2   4   7
Induction and recursion
Chapter 4 (Part 2): Mathematical Reasoning, Induction & Recursion
Recursion.
Presentation transcript:

22C:19 Discrete Structures Induction and Recursion Spring 2014 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

Recursive definition of a full binary tree Basis. A single vertex is a full binary tree Recursive step. If T1 and T2 are disjoint full binary trees, then a full binary tree T1.T2 consisting of a root r and edges connecting r to each of the roots of T1 and T2 is a full binary tree.

Recursive definition of the height of a full binary tree Basis. The height full binary tree T consisting of only a root is h(T)= 0 Recursive step. If T1 and T2 are two full binary trees, then the full binary tree T= T1.T2 has height h(T)= 1 + (max h(T1), h(T2)

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 proof of it using structural induction. We will work it out in the class.

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 )