13.2 Recursive Definitions Objective 1) Provide the recursive definition for sequences; 2) Identify the type of a sequence from a recursive definition.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms II
Advertisements

Tower of Hanoi Tower of Hanoi is a mathematical puzzle invented by a French Mathematician Edouard Lucas in The game starts by having few discs stacked.
Week 6 - Wednesday CS322.
Chapter 8 Recursion. 8.1 Recursively Defined Sequences.
Chapter Recurrence Relations
Recursion Lecture 18: Nov 18.
CS 2210 (22C:19) Discrete Structures Advanced Counting
Kavita Math231 Recursion and Iteration. Kavita Math231 We use Recursion when we have to perform a complex task that can be broken into the several subtasks.
CSE115/ENGR160 Discrete Mathematics 04/21/11 Ming-Hsuan Yang UC Merced 1.
Recursion.
Chapter 7 Review. Simplify, no negative exponents.
1 Section 6.1 Recurrence Relations. 2 Recursive definition of a sequence Specify one or more initial terms Specify rule for obtaining subsequent terms.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 5. Recursive Algorithms.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
13.2: Arithmetic and Geometric Sequences Recursive Definitions.
7.5 Use Recursive Rules with Sequences and Functions
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Copyright © Cengage Learning. All rights reserved.
Recursively Defined Sequences Lecture 35 Section 8.1 Wed, Mar 23, 2005.
Applied Discrete Mathematics Week 9: Relations
Advanced Counting Techniques
1 © 2010 Pearson Education, Inc. All rights reserved 10.1 DEFINITION OF A SEQUENCE An infinite sequence is a function whose domain is the set of positive.
Analysis of Algorithm Lecture 3 Recurrence, control structure and few examples (Part 1) Huma Ayub (Assistant Professor) Department of Software Engineering.
RMIT University; Taylor's College1 Lecture 6  To apply the Principle of Mathematical Induction  To solve the Towers of Hanoi puzzle  To define a recurrence.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
CSC201 Analysis and Design of Algorithms Asst.Proof.Dr.Surasak Mungsing Oct-151 Lecture 2: Definition of algorithm and Mathematical.
CSE 2813 Discrete Structures Recurrence Relations Section 6.1.
Module #20 - Recurrences 1 Ch. 7 Recurrence Relations Rosen 6 th ed., §§7.1.
Module #17: Recurrence Relations Rosen 5 th ed., §
Review Introduction to Searching External and Internal Searching Types of Searching Linear or sequential search Binary Search Algorithms for Linear Search.
Sequences and Summations
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Recurrence.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Chapter 8 With Question/Answer Animations. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Sequences and Summations Section 2.4. Section Summary Sequences. – Examples: Geometric Progression, Arithmetic Progression Recurrence Relations – Example:
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
1 Topics Recursion sections 8.1 – Recursion A recursively defined sequence –First, certain initial values are specified –Later terms of the sequence.
Lecture - 8 On Stacks, Recursion. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Lecture Outline Quick sort Algorithm Recursion –Calculate n factorial –Fibonacci.
Algebra II Chapter : Use Recursive Rules with Sequences and Functions HW: p (4, 10, 14, 18, 20, 34)
22C:19 Discrete Math Advanced Counting Fall 2010 Sukumar Ghosh.
Recursion Colin Capham Recursion – an introduction to the concept.
RECURRENCE Sequence Recursively defined sequence
Discrete Mathematics Lecture # 22 Recursion.  First of all instead of giving the definition of Recursion we give you an example, you already know the.
11.2 & 11.3: Sequences What is now proven was once only imagined. William Blake.
4.2B Geometric Explicit and Recursive Sequences
Arithmetic and Geometric Sequences. Determine whether each sequence is arithmetic, geometric, or neither. Explain your reasoning. 1. 7, 13, 19, 25, …2.
Sequences and the Binomial Theorem Sequences Arithmetic Sequences Geometric Sequences & Series Binomial Theorem.
1 RECURRENCE 1. Sequence 2. Recursively defined sequence 3. Finding an explicit formula for recurrence relation.
1 CS1120: Recursion. 2 What is Recursion? A method is said to be recursive if the method definition contains a call to itself A recursive method is a.
Recursively Defined Sequences Lecture 40 Section 8.1 Wed, Apr 11, 2007.
Discrete Math For Computing II. Contact Information B. Prabhakaran Department of Computer Science University of Texas at Dallas Mail Station EC 31, PO.
Using Recursive Rules with Sequences
Introduction to Recurrence Relations
Arithmetic & Geometric Sequences
Sequences and Series College Algebra
Discrete Math (2) Haiming Chen Associate Professor, PhD
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
CS 2210 Discrete Structures Advanced Counting
Module 3 Arithmetic and Geometric Sequences
Write the recursive and explicit formula for the following sequence
Mathematical Induction
8.5 Using Recursive Rules with Sequences
Recurrence Relations Rosen 5th ed., §6.2 5/22/2019
Module 3 Arithmetic and Geometric Sequences
Recursively Defined Sequences
Lesson 6.7 Recursive Sequences
Presentation transcript:

13.2 Recursive Definitions Objective 1) Provide the recursive definition for sequences; 2) Identify the type of a sequence from a recursive definition.

Recursively Defined Sequences Often it is difficult to express the members of an object or numerical sequence explicitly. Example: The Fibonacci sequence: {f n } = 0,1,1,2,3,5,8,13,21,34,55,… There may, however, be some “local” connections that can give rise to a recursive definition – a formula that expresses higher terms in the sequence, in terms of lower terms.

Recursively Defined Sequences To define a sequence recursively, it must consists two parts: give initial condition(s), i.e., the value(s) of the first (few) term(s) explicitly (that tells where the sequence starts); give a recurrence relation, i.e., an equation that relates any term in the sequence to the preceding term(s). Example: Define the following sequence recursively: 1, 4, 7, 10, 13, … Solution: a 1 = 1, (initial condition) a n = a n–1 + 3 for n≥2(recurrence relation) Example: Recursive definition for {f n }: f 0 = 0, f 1 = 1 (initial condition) f n = f n – 1 + f n – 2 for n > 1. (recurrence relation)

Recursively defined sequences In 13.1 and 13.3, we have learned the explicit definitions for sequences. The same sequence can be defined explicitly as: Example: Define the following sequence explicitly: 1, 4, 7, 10, 13, … Solution: a n = 1 + (n – 1)  3 = 3n – 2 We learned from this example that it may have both explicit definition and recursive definition for the same sequence.

Recursion is one of the central ideas of computer science To solve a problem recursively Break it down into smaller subproblems each having the same form as the original problem; When the process is repeated many times, the last of the subproblems are small and easy to solve; The solutions of the subproblems can be woven together to form a solution to the original problem. Example: The tower of Hanoi (P. 484 #31)

RULES: You may only move one disk at a time. A disk may only be moved to one of the three columns. You must never place a larger disk on top of a smaller disk. INITIAL STATE GOAL STATE Tower of Hanoi: Move disks from left pole to right pole Pole A Pole B Pole C

The Tower of Hanoi How to generalize the procedure to n disks? How many moves are required? Recursive procedure: (1) Transfer the top n – 1 disks from pole A to pole B (2) Move the bottom disk from pole A to pole C (3) Transfer the top n – 1 disks from pole B to pole C Let a n denote the number of moves needed to transfer a tower of n disks from one pole to another using the above procedure. Then we have the following recursive relations for counting the moves: If n = 1 (or only 1 disk), then a 1 = 1 and all done.

The Tower of Hanoi Recursive procedure: (1) Transfer the top n – 1 disks from pole A to pole B (2) Move the bottom disk from pole A to pole C (3) Transfer the top n – 1 disks from pole B to pole C If n  2, then the recursive procedure (1) requires a n–1 moves, the recursive procedure (2) needs 1 moves, and recursive procedure (3) still takes a n–1 moves. So the recursive definition for the Tower of Hanoi is a n = a n– a n–1 for n ≥ 2 or a n = 2a n–1 + 1 for n ≥ 2

Recursive Formula for Compound Interest Example: Suppose $10K is deposited in an account paying 3% interest compounded annually. For each positive integer n, let A 0 = the initial amount deposited; A n = the amount on deposit at the end of year n. Find a recursive relation for A 0, A 1, A 2,… assuming no additional deposits or withdrawals. We have the following recursive formula: A 0 = 10,000 A n = A n  A n-1 = 1.03  A n-1 for n≥1

Finding an Explicit Formula for a Recursively Defined Sequence It is often helpful to know an explicit formula for the sequence, especially if you need to compute terms with very large subscripts; to examine general properties of the sequence. Example Recall the recursive formula for the compound interest example: A 0 = 10,000 A n = 1.03  A n-1 for n≥1 The explicit formula is A n =  (1.03) n for n≥0 Note: this formula can be generalized to any geometric sequence.

Example (cont.) Suppose the sequence is given by the following recursive relation: a 0 = 3 a n = a n for n≥1 Then the explicit formula is a n =  n for n≥0 Note: this formula can be generalized to any arithmetic sequence. Finding an Explicit Formula for a Recursively Defined Sequence

Example (cont.) Recall the recursive formula for the Hanoi Tower example: a 1 = 1 a n = 2a n for n≥2 How to get explicit formula? Compute the first few terms of this sequence: a 1 = 1 a 2 = 3 a 3 = 7 a 4 = 15 a 5 = 31 a 6 = 63 Based on the pattern, a n = 2 n – 1 for n≥1 The explicit definition for Hanoi Tower problem is very hard. Finding an Explicit Formula for a Recursively Defined Sequence = 2 1 – 1, = 2 2 – 1, = 2 3 – 1, = 2 4 – 1, = 2 5 – 1,= 2 6 – 1,

Note the difference between explicit definition and recursive definition 1.Explicit definition An explicit definition gives a n as a function of n. 2.Recursive definition Gives the initial term(s) and a recursive equation that tells how a n is related to one or more of the preceding terms.

One Important Note For a sequence, it may have both explicit definition and recursive definition. It also may have more than one recursive definition(equation). Examples are: 1.Suppose {a n } is an arithmetic sequence with common difference d. Then the explicit definition is a n = a 1 + (n – 1)d recursive definition 1 is a 1 = , a n = a n-1 + d recursive definition 2 is a 1 = , a 2 = , a n = 2a n-1 – a n-2 2. Suppose {b n } is a geometric sequence with common ration r. Then the explicit definition is b n = b 1 r n-1 recursive definition 1 is b 1 = , b n = rb n-1 Recursive definition 2 is

Example P. 482 #23. 1.Suppose that S n represents the number of dots in an n by n square array. Give a recursion equation that tells how S n+1 is related to S n. S 1 = 1, S n+1 = S n + n + n +1 S 1 = 1, S n+1 = S n + 2n + 1 for n ≥ 1 n n SnSn How to get explicit formula? Compute the first few terms of this sequence: S 1 = 1 S 2 = 4 S 3 = 9 S 4 = 16 S 5 = 25 S 6 = 36 Based on the pattern, S n = n 2 for n≥1.

Note Some sequences may have more than one recursive definition: For example, any arithmetic sequence with common difference d can be expressed as a 1 = c a n = a n-1 + d for n≥2 Or, it may also be defined as a 1 = b, a 2 = c a n = 2a n-1 – a n-2 for n≥3.

Note Some sequences may have more than one recursive definition: For example, any geometric sequence with common ratio r can be expressed as a 1 = c a n = r a n-1, for n≥2 Or, it may also be defined as a 1 = b, a 2 = c a n = (a n-1 ) 2 /a n-2 for n≥3.

Assignment P. 481 #1 – 22, 24, 29, 30, 32