Module #20 - Recurrences 1 Ch. 7 Recurrence Relations Rosen 6 th ed., §§7.1.

Slides:



Advertisements
Similar presentations
Chapter Recurrence Relations
Advertisements

Chapter 6 Advanced Counting 6.1 Recurrence Relations.
Recursion Lecture 18: Nov 18.
1 Recursive Algorithm Analysis Dr. Ying Lu RAIK 283: Data Structures & Algorithms September 13, 2012.
CS 2210 (22C:19) Discrete Structures Advanced Counting
Recurrences. What is a Recurrence Relation? A system of equations giving the value of a function from numbers to numbers in terms of the value of the.
Recursion. Idea: Some problems can be broken down into smaller versions of the same problem Example: n! 1*2*3*…*(n-1)*n n*factorial of (n-1)
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. 2 CMPS 12B, UC Santa Cruz Solving problems by recursion How can you solve a complex problem? Devise a complex solution Break the complex problem.
Recursion.
Chapter 6 Recurrence and Solution. 6.2 Recurrence Relation 6.3 Solve Homogeneous Recurrence 6.4 Solve Nonhomogeneous Recurrence.
1 Section 6.1 Recurrence Relations. 2 Recursive definition of a sequence Specify one or more initial terms Specify rule for obtaining subsequent terms.
COMPSCI 105 S Principles of Computer Science Recursion 3.
6.Advanced Counting Techniques 1 Copyright M.R.K. Krishna Rao 2003 Ch 6. Recurrence Relations A recurrence relation for the sequence {a n } is an equation.
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Recursion Apan Qasem Texas State University Spring 2011.
Recursively Defined Sequences Lecture 35 Section 8.1 Wed, Mar 23, 2005.
Applied Discrete Mathematics Week 9: Relations
Advanced Counting Techniques
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Chap. 7 (c) , Michael P. Frank1 Chapter 7: Advanced Counting Techniques.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
13.2 Recursive Definitions Objective 1) Provide the recursive definition for sequences; 2) Identify the type of a sequence from a recursive definition.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Ch. 7: Advanced Counting Techniques
14.1 CompSci 102© Michael Frank Today’s topics Recurrence relationsRecurrence relations –Stating recurrences –LiHoReCoCo –Divide & conquer –Master’s method.
Recurrence Relation. Outline  What is a recurrence relation ?  Solving linear recurrence relations  Divide-and-conquer algorithms and recurrence relations.
CSE 2813 Discrete Structures Recurrence Relations Section 6.1.
R. Johnsonbaugh Discrete Mathematics 7 th edition, 2009 Chapter 7 Recurrence Relations Instructor Tianping Shuai.
15.1 CompSci 102© Michael Frank Today’s topics Recurrence relationsRecurrence relations –Stating recurrences –LiHoReCoCo Reading: Sections Reading:
Module #17: Recurrence Relations Rosen 5 th ed., §
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/18 Module.
Chapter 7 Advance Counting Techniques. Content Recurrence relations Generating function The principle of inclusion-exclusion.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Recurrence.
Informal Analysis of Merge Sort  suppose the running time (the number of operations) of merge sort is a function of the number of elements to sort  let.
Chapter 8 With Question/Answer Animations. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
after UCI ICS/Math 6A, Summer AdvancedCounting -1 Recurrence Relations (RRs) A “Recurrence Relation”
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.
Chapter 6.1: Recurrence Relations Discrete Mathematical Structures: Theory and Applications.
Discrete Mathematics Recurrence Relations Chapter 5 R. Johnsonbaugh
22C:19 Discrete Math Advanced Counting Fall 2010 Sukumar Ghosh.
CHAPTER TWO RECURRENCE RELATION
Agenda Lecture Content:  Recurrence Relations  Solving Recurrence Relations  Iteration  Linear homogenous recurrence relation of order k with constant.
8.1: Recurrence Relations We touched on them briefly before; we’ll dive deeper here. We aren’t going to focus on solving them, but you should know how.
Discrete Mathematics Lecture # 22 Recursion.  First of all instead of giving the definition of Recursion we give you an example, you already know the.
1 Recursion Recursive function: a function that calls itself (directly or indirectly). Recursion is often a good alternative to iteration (loops). Its.
1 In this puzzle, the player begins with n disks of decreasing diameter placed one on top of the other on one of three pegs of the game board. The player.
Recursively Defined Sequences Lecture 40 Section 8.1 Wed, Apr 11, 2007.
Aumm-e-hani munir Maria umer Rakhshanda batool Faiza.
Discrete Math For Computing II. Contact Information B. Prabhakaran Department of Computer Science University of Texas at Dallas Mail Station EC 31, PO.
Tower of Hanoi problem: Move the pile of rings from one peg to another
CMSC Discrete Structures
Introduction to Recurrence Relations
Module #17: Recurrence Relations
Tower of Hanoi problem: Move the pile of rings from one peg to another
Module #17: Recurrence Relations
CS 2210 Discrete Structures Advanced Counting
CMSC Discrete Structures
Applied Discrete Mathematics Week 7: Computation
CMSC Discrete Structures
Recurrence Relations Discrete Structures.
Chapter 7 Advanced Counting Techniques
Chapter 3 :Recursion © 2011 Pearson Addison-Wesley. All rights reserved.
Recurrence Relations (RRs)
Recurrence Relations Rosen 5th ed., §6.2 5/22/2019
ICS 253: Discrete Structures I
Tower of Hanoi problem: Move the pile of rings from one peg to another
Recursively Defined Sequences
Presentation transcript:

Module #20 - Recurrences 1 Ch. 7 Recurrence Relations Rosen 6 th ed., §§7.1

Module #20 - Recurrences 2 §7.1: Recurrence Relations A recurrence relation (R.R., or just recurrence) for a sequence {a n } is an equation that expresses a n in terms of one or more previous elements a 0, …, a n−1 of the sequence, for all n≥n 0.A recurrence relation (R.R., or just recurrence) for a sequence {a n } is an equation that expresses a n in terms of one or more previous elements a 0, …, a n−1 of the sequence, for all n≥n 0. –I.e., just a recursive definition, without the base cases. A particular sequence (described non-recursively) is said to solve the given recurrence relation if it is consistent with the definition of the recurrence.A particular sequence (described non-recursively) is said to solve the given recurrence relation if it is consistent with the definition of the recurrence. –A given recurrence relation may have many solutions.

Module #20 - Recurrences 3 Recurrence Relation Example Consider the recurrence relationConsider the recurrence relation a n = 2a n−1 − a n−2 (n≥2). Which of the following are solutions? a n = 3n a n = 2 nWhich of the following are solutions? a n = 3n a n = 2 n a n = 5 a n = 5 Yes No

Module #20 - Recurrences 4 Example Applications Recurrence relation for growth of a bank account with P% interest per given period:Recurrence relation for growth of a bank account with P% interest per given period: M n = M n−1 + (P/100)M n−1 Growth of a population in which each organism yields 1 new one every period starting 2 time periods after its birth.Growth of a population in which each organism yields 1 new one every period starting 2 time periods after its birth. P n = P n−1 + P n−2 (Fibonacci relation)

Module #20 - Recurrences 5 Solving Compound Interest RR M n = M n−1 + (P/100)M n−1M n = M n−1 + (P/100)M n−1 = (1 + P/100) M n−1 = r M n−1 (let r = 1 + P/100) = r (r M n−2 ) = r·r·(r M n−3 )…and so on to… = r n M 0

Module #20 - Recurrences 6 Tower of Hanoi Example Problem: Get all disks from peg 1 to peg 2.Problem: Get all disks from peg 1 to peg 2. –Rules: (a) Only move 1 disk at a time. –(b) Never set a larger disk on a smaller one. Peg #1Peg #2Peg #3

Module #20 - Recurrences 7 Hanoi Recurrence Relation Let H n = # moves for a stack of n disks.Let H n = # moves for a stack of n disks. Here is the optimal strategy:Here is the optimal strategy: –Move top n−1 disks to spare peg. (H n−1 moves) –Move bottom disk. (1 move) –Move top n−1 to bottom disk. (H n−1 moves) Note that: H n = 2H n−1 + 1Note that: H n = 2H n−1 + 1 –The # of moves is described by a Rec. Rel.

Module #20 - Recurrences 8 Solving Tower of Hanoi RR H n = 2 H n−1 + 1 = 2 (2 H n−2 + 1) + 1 = 2 2 H n− = 2 (2 H n−2 + 1) + 1 = 2 2 H n− = 2 2 (2 H n−3 + 1) = 2 3 H n− = 2 2 (2 H n−3 + 1) = 2 3 H n− … = 2 n−1 H n−2 + … = 2 n−1 H n−2 + … = 2 n−1 + 2 n−2 + … (since H 1 = 1) = 2 n−1 + 2 n−2 + … (since H 1 = 1) = = 2 n − 1 = 2 n − 1

Module #20 - Recurrences 9 Another R.R. Example Find a R.R. & initial conditions for the number of bit strings of length n without two consecutive 0s.Find a R.R. & initial conditions for the number of bit strings of length n without two consecutive 0s. We can solve this by breaking down the strings to be counted into cases that end in 0 and in 1.We can solve this by breaking down the strings to be counted into cases that end in 0 and in 1. –For each ending in 0, the previous bit must be 1, and before that comes any qualifying string of length n−2. –For each string ending in 1, it starts with a qualifying string of length n−1. Thus, a n = a n−1 + a n−2. (Fibonacci recurrence.)Thus, a n = a n−1 + a n−2. (Fibonacci recurrence.) –The initial conditions are: a 0 = 1 (ε), a 1 = 2 (0 and 1). 10(n−2 bits)1(n−1 bits)