Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011

Slides:



Advertisements
Similar presentations
Jessie Zhao Course page: 1.
Advertisements

22C:19 Discrete Structures Induction and Recursion Spring 2014 Sukumar Ghosh.
22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
Recursive Definitions and Structural Induction
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.
CSE115/ENGR160 Discrete Mathematics 04/03/12 Ming-Hsuan Yang UC Merced 1.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
CSE 321 Discrete Structures Winter 2008 Lecture 12 Induction.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
CSE115/ENGR160 Discrete Mathematics 03/31/11
Lecture Recursive Definitions. Fractals fractals are examples of images where the same elements is being recursively.
Lecture Recursive Definitions. Fractals fractals are examples of images where the same elements is being recursively.
Chapter Mathematical Induction
1 Section 3.4 Recursive Definitions. 2 Recursion Recursion is the process of defining an object in terms of itself Technique can be used to define sequences,
Induction and recursion
22C:19 Discrete Math Induction and Recursion Fall 2011 Sukumar Ghosh.
Induction and recursion
Analysis of Recursive Algorithms October 29, 2014
Recursive Definitions and Structural Induction
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
Induction and recursion
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 4 Induction and Recursion 歐亞書局.
Chapter 4: Induction and Recursion
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
Chapter 7 Recursion 1CSCI 3333 Data Structures. 2 Recurrent Sequence A recursively defined sequence – First, certain initial values are specified  c.f.,
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.
Analyzing Complexity of Lists OperationSorted Array Sorted Linked List Unsorted Array Unsorted Linked List Search( L, x ) O(logn) O( n ) O( n ) Insert(
1 Recurrences Algorithms Jay Urbain, PhD Credits: Discrete Mathematics and Its Applications, by Kenneth Rosen The Design and Analysis of.
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.
CompSci 102 Discrete Math for Computer Science April 17, 2012 Prof. Rodger.
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.
Cpt S 223 – Advanced Data Structures Math Review 2
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.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Math Review 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.
1 CMSC 341 Math Review. 2 Exponents Identities (X A ) B = X AB X A * X B = X A+B X A / X B = X A-B X A + X B  X A+B.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
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.
Chapter 6 (Lafore’s Book) Recursion Hwajung Lee.  Definition: An algorithmic technique. To solve a problem on an instance of size n, the instance is:
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.
CSE 311 Foundations of Computing I Lecture 15 Strong Induction and Recursive Definitions Spring
Mathematical Induction And Recursion Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Chapter 4: Induction and Recursion
Induction and recursion
Induction and Recursion Chapter 5
CS2210:0001Discrete Structures Induction and Recursion
Induction and Recursion
Discrete Structures for Computer Science
Lecture Outline for Recurrences
Intro to Recursion.
Discrete Structures for Computer Science
CSE 321 Discrete Structures
CS 250, Discrete Structures, Fall 2015 Nitesh Saxena
Chapter 4 Induction and Recursion
Rosen 5th ed., §§ ~18 slides, ~1 lecture
Discrete Mathematics and its Applications
Induction and recursion
ITEC324 Principle of CS III
Chapter 4 (Part 2): Mathematical Reasoning, Induction & Recursion
CSE 311 Foundations of Computing I
Discrete Mathematics and its Applications
Presentation transcript:

Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011 Suprakash Datta datta@cse.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cse.yorku.ca/course/1019 5/10/2019

Next: Recursion Important in mathematics, programming, thinking about problems 5/10/2019

Recursive definitions In many cases – a natural way of thinking Ex. 1: f(0) = b, and  i>0 f(i)= f(i-1)+a Ex. 2: f(0) = b, and  i>0 f(i)= f(i-1)*a Ex. 3: f(0) = 1, f(1) = 1 and  i>1 f(i)= f(i-1)+f(i-2) Arithmetic progression Geometric progression Fibonacci series 5/10/2019

Full binary trees Each node has 0 successors 2 successors, each of which is a full binary tree Special case: complete binary tree The two successors of a node are complete binary trees with the same number of nodes 5/10/2019

Height of full binary trees Recursive definition of height h(T) If no of nodes n(T) =1, h(T) =0 Else the height is 1 + max(h(T1),h(T2)) where T1, T2 are the two subtrees of T Theorem: If T is a full binary tree, then n(T)  2h(T)+1 -1 Proof: By structural induction 5/10/2019

Structural induction To prove n(T)  2h(T)+1 -1 Base case: If n(T) = 1, h(T) = 0, so the proposition holds. Inductive step: 5/10/2019

Simple recursive programs Factorial Fibonacci Binary search Merge sort 5/10/2019

Correctness of recursive programs Merge sort Inductively assume the two recursive calls correct Prove the correctness of the merge step By strong induction the algorithm is correct 5/10/2019

Drawbacks of recursion Repeated computation of the same terms Wasted storage Overhead incurred by OS due to stack maintenance 5/10/2019

Analyzing recursive programs Mergesort f(n) = 2f(n/2) + n What constitutes a “solution”? How do you solve this recurrence? 5/10/2019

Next More uses of recursion 5/10/2019

Recursively defined sets Basis step: 2  S Recursive step: If x  S and y  S then x+ y  S Defines the set {2k|k=1,2,3,…} What happens if we change the recursive step to: If x  S and y  S then x+y  S, x-y  S ? 5/10/2019

Recursively defined sets - 2 All possible strings (*) over alphabet  Basis step:   * Recursive step: If x   and w  * then wx  * Length of a string l() = 0 l(wx) = l(w) + 1 if x   and w  * 5/10/2019

Recursively defined sets - 3 What is this set A defined over  = {0,1}? Basis step:   A Recursive step: If x  A then 0x1  A What is this set B defined over  = {0,1}? Basis step:   B Recursive step: If x B then 0x1  B and 1x0  B 5/10/2019

Recursively defined sets - 4 Data structures – full binary trees Basis step: single vertex Recursive step: If S, T are full binary trees then the following is a full binary tree r T S 5/10/2019