Handout 7: Recurrences (Cont d)

Size: px
Start display at page:

Download "Handout 7: Recurrences (Cont d)"

Transcription

1 ENGG 2440B: Discrete Mathematics for Engineers Handout 7: Recurrences (Cont d) First Term Instructor: Anthony Man Cho So October 8, 2018 In the last handout, we studied techniques for solving linear homogeneous recurrences. We now build upon those techniques to solve a more general class of recurrences, namely, the class of linear inhomogeneous recurrences. 1 Introduction Consider the following recurrence: T (n) = a 1 T (n 1) + a 2 T (n 2) + + a d T (n d) + F (n). (1) At first sight, this is similar to a linear homogeneous recurrence. However, there is an extra term F (n) at the end, which is unrelated to T (n) and requires some new machinery to handle. Before we discuss the techniques for solving (1), let us see how such recurrence arises. Example 1 Consider 3 pegs, where n circular disks of increasing size are placed in one peg with the largest disk at the bottom. These disks are to be transferred one at a time onto another of the pegs, with the requirements that (i) at no time is one allowed to place a larger disk on top of a smaller one and (ii) at the end one must have all the disks in one peg that is different from the initial one. How many moves are needed to complete the task? This is the famous Tower of Hanoi puzzle. Let T (n) be the number of moves needed to transfer the n disks. Then, it is easy to convince youself that T (1) = 1 and T (2) = 3. Now, observe that to transfer n disks to another peg, we must first transfer the top n 1 disks to a peg, then transfer the largest disk to the vacant peg, and finally transfer the n 1 disks to the peg that contains the largest disk. The above process can be described by the recurrence T (n) = T (n 1) T (n 1) = 2T (n 1) + 1 for n 1 (2) with the initial condition T (1) = 1. The recurrence (2) is a special case of (1), with d = 1, a 1 = 2, and F (n) = 1. 2 Solving Linear Inhomogeneous Recurrences The technique for solving the linear inhomogeneous recurrence (1) largely relies on that for solving the associated linear homogeneous recurrence Indeed, we have the following result: T (n) = a 1 T (n 1) + a 2 T (n 2) + + a d T (n d). (3) Theorem 1 Let T p (n) be a particular solution to the linear inhomogeneous recurrence (1) and T h (n) be a homogeneous solution to the associated linear homogeneous recurrence (3). Then, every solution to (1) is of the form T 0 (n) = T h (n) + T p (n). 1

2 The proof of Theorem 1 is rather straightforward. Proof If T h (n) solves (3) and T p (n) solves (1), then by definition, T h (n) = a 1 T h (n 1) + a 2 T h (n 2) + + a d T h (n d), T p (n) = a 1 T p (n 1) + a 2 T p (n 2) + + a d T p (n d) + F (n). Upon adding the above two equations, we obtain (T h (n) + T p (n)) = a 1 (T h (n 1) + T p (n 1)) + a 2 (T h (n 2) + T p (n 2)) + + a d (T h (n d) + T p (n d)) +F (n), which implies that T 0 (n) = T h (n) + T p (n) also solves (1). Since we already know how to find solutions to the linear homogeneous recurrence (3), to apply Theorem 1, it remains to investigate how we can come up with a particular solution to the linear inhomogeneous recurrence (1). In many cases, the particular solution will be of the same function class as the inhomogeneous term F (n). For instance, if F (n) is a polynomial in n of degree t, then T p (n) will also be a polynomial in n whose degree is at least t. Let us illustrate this by continuing Example 1. Example 1 (cont d) Since F (n) = 1, which is a polynomial of degree 0, we can try the particular solution T p (n) = x, where x is a constant to be determined. Note that T p (n) = x is a polynomial of degree 0. Now, if T p (n) solves the recurrence (2), then we must have x = 2x + 1, which means that x = 1. Hence, T p (n) = 1 is a particular solution to (2). Now, by Theorem 1, in order to solve (2), we also need the solution to its associated linear homogeneous recurrence T (n) = 2T (n 1). (4) The characteristic equation associated with (4) is x = 2. Hence, for any real number θ, is a solution to (4). By Theorem 1, T h (n) = θ2 n T 0 (n) = T h (n) + T p (n) = θ2 n 1 is a solution to (2). It remains to impose the initial condition to determine θ. Since T (1) = 1, we have 1 = 2θ 1, which gives θ = 1. It follows that T (n) = 2 n 1 is the solution to the Tower of Hanoi recurrence (2). We shall further elaborate on how to find a particular solution to a given linear inhomogeneous recurrence in Section 3. Now, let us first summarize the procedure we developed so far for solving the linear inhomogeneous recurrence (1): Procedure for Solving Linear Inhomogeneous Recurrence 2

3 1. Solve the associated linear homogeneous recurrence (3) using the techniques introduced in Handout 6 to get the homogeneous solution T h (n). Note that T h (n) takes the form T h (n) = θ 1 T 1 (n) + θ 2 T 2 (n) + + θ d T d (n), where T 1 (n),..., T d (n) are the functions determined by the roots of the characteristic equation associated with (3) and θ 1,..., θ d are any real numbers. 2. Find a particular solution T p (n) to the linear inhomogeneous recurrence (1) by examining the function class of F (n). 3. Form the candidate solution T 0 (n) = T h (n)+t p (n) and use the initial conditions on T (1),..., T (d) to fix the parameters θ 1,..., θ d in T h (n). 3 Finding a Particular Solution As mentioned earlier, the particular solution is often of the same function class as the inhomogeneous term F (n) in (1). More precisely, we have the following result, which informally states that if F (n) takes the form F (n) = p(n)s n, where p(n) is a polynomial in n and s is a constant, then there is a particular solution T p (n) to (1) that takes the form T p (n) = q(n)s n, where q(n) is another polynomial in n. Theorem 2 Suppose that the inhomogeneous term F (n) in (1) takes the form F (n) = (b 0 + b 1 n + b 2 n b t n t )s n (5) for some real numbers b 0, b 1,..., b t and s. If s is not a root of the characteristic equation associated with the linear homogeneous recurrence (3), then there is a particular solution T p (n) to (1) of the form T p (n) = (x 0 + x 1 n + x 2 n x t n t )s n, for some real numbers x 0, x 1,..., x t. On the other hand, if s is a root of the characteristic equation associated with the linear homogeneous recurrence (3) of multiplicity m 1, then there is a particular solution T p (n) to (1) of the form T p (n) = n m (x 0 + x 1 n + x 2 n x t n t )s n, for some real numbers x 0, x 1,..., x t. In the context of Example 1, we have F (n) = 1, which means that b 0 = 1, b 1 = b 2 = = b t = 0, and s = 1 in (5). Since s = 1 is not a root of the characteristic equation (4), by Theorem 2, there is a particular solution of the form T p (n) = x 0. This is consistent with our choice in Example 1. Let us present some more examples to illustrate the procedure for solving linear inhomogeneous recurrences. Example 2 Consider the recurrence { T (n) = 5T (n 1) 6T (n 2) + 7 n for n 2, T (0) = 0, T (1) = 1. (6) 3

4 The associated linear homogeneous recurrence is whose characteristic equation is given by T (n) = 5T (n 1) 6T (n 2), The roots are r 1 = 3 and r 2 = 2. Hence, for any real numbers θ 1, θ 2, x 2 = 5x 6. (7) T h (n) = θ 1 3 n + θ 2 2 n is a homogeneous solution. Now, let us find a particular solution to the recurrence (6). Note that F (n) = 7 n and s = 7 is not a root of the characteristic equation (7). Hence, by Theorem 2, the particular solution T p (n) should take the form T p (n) = x 0 7 n for some constant x 0. Substituting this into (6) yields x 0 7 n = 5x 0 7 n 1 6x 0 7 n n. Upon simplifying and solving for x 0, we get x 0 = Thus, our candidate solution to the recurrence (6) is T 0 (n) = T h (n) + T p (n) = θ 1 3 n + θ 2 2 n n. Lastly, using our initial conditions, we get 0 = T 0 (0) = θ 1 + θ , 1 = T 0 (1) = 3θ 1 + 2θ This gives θ 1 = and θ 2 = Hence, the solution to the recurrence (6) is given by T (n) = n n n. Example 3 Consider the recurrence { T (n) = 6T (n 1) 9T (n 2) + 3 n for n 2, T (0) = 0, T (1) = 1 2. (8) The associated linear homogeneous recurrence is whose characteristic equation is given by T (n) = 6T (n 1) 9T (n 2), x 2 = 6x 9. (9) 4

5 The root r = 3 is repeated and has multiplicity 2. Hence, by Theorem 2 of Handout 6, for any real numbers θ 1, θ 2, T h (n) = θ 1 3 n + θ 2 n3 n is a homogeneous solution. To find a particular solution to (8), we note that F (n) = 3 n and s = 3 is a root of the characteristic equation (9) of multiplicity 2. Hence, by Theorem 2, the particular solution T p (n) should take the form T p (n) = x 0 n 2 3 n for some constant x 0. Substituting this into (8) yields x 0 n 2 3 n = 6x 0 (n 1) 2 3 n 1 9x 0 (n 2) 2 3 n n. Upon simplifying and solving for x 0, we get x 0 = 1 2. Thus, our candidate solution to the recurrence (8) is given by Lastly, using the initial conditions, we have T 0 (n) = T h (n) + T p (n) = θ 1 3 n + θ 2 n3 n n2 3 n. 0 = T 0 (0) = θ 1, 1 2 = T 0(1) = 3θ 1 + 3θ , which gives θ 1 = 0 and θ 2 = 1 3. It follows that the solution to the recurrence (8) is given by T (n) = 1 3 n3n n2 3 n. 5

Part III, Sequences and Series CS131 Mathematics for Computer Scientists II Note 16 RECURRENCES

Part III, Sequences and Series CS131 Mathematics for Computer Scientists II Note 16 RECURRENCES CS131 Part III, Sequences and Series CS131 Mathematics for Computer Scientists II Note 16 RECURRENCES A recurrence is a rule which defines each term of a sequence using the preceding terms. The Fibonacci

More information

Linear Recurrence Relations

Linear Recurrence Relations Linear Recurrence Relations Linear Homogeneous Recurrence Relations The Towers of Hanoi According to legend, there is a temple in Hanoi with three posts and 64 gold disks of different sizes. Each disk

More information

Jong C. Park Computer Science Division, KAIST

Jong C. Park Computer Science Division, KAIST Jong C. Park Computer Science Division, KAIST Today s Topics Introduction Solving Recurrence Relations Discrete Mathematics, 2008 2 Computer Science Division, KAIST Definition A recurrence relation for

More information

Math.3336: Discrete Mathematics. Advanced Counting Techniques

Math.3336: Discrete Mathematics. Advanced Counting Techniques Math.3336: Discrete Mathematics Advanced Counting Techniques Instructor: Dr. Blerina Xhabli Department of Mathematics, University of Houston https://www.math.uh.edu/ blerina Email: blerina@math.uh.edu

More information

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt Lecture 3 The Analysis of Recursive Algorithm Efficiency What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency

More information

Tutorial 2 WANG PENG. Department of Systems Engineering and Engineering Management, The Chinese University of Hong Kong. September 28, 2017

Tutorial 2 WANG PENG. Department of Systems Engineering and Engineering Management, The Chinese University of Hong Kong. September 28, 2017 Tutorial 2 WANG PENG Department of Systems Engineering and Engineering Management, The Chinese University of Hong Kong September 28, 2017 WANG PENG (ENGG 2440B) Tutorial 2 September 28, 2017 1 / 17 Outline

More information

Notes for Recitation 14

Notes for Recitation 14 6.04/18.06J Mathematics for Computer Science October 7, 006 Tom Leighton and Ronitt Rubinfeld Notes for Recitation 14 Guessing a Particular Solution A general linear recurrence has the form: fn) = b 1

More information

MI 4 Mathematical Induction Name. Mathematical Induction

MI 4 Mathematical Induction Name. Mathematical Induction Mathematical Induction It turns out that the most efficient solution to the Towers of Hanoi problem with n disks takes n 1 moves. If this isn t the formula you determined, make sure to check your data

More information

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee Algorithm Analysis Recurrence Relation Chung-Ang University, Jaesung Lee Recursion 2 Recursion 3 Recursion in Real-world Fibonacci sequence = + Initial conditions: = 0 and = 1. = + = + = + 0, 1, 1, 2,

More information

Learning Objectives

Learning Objectives Learning Objectives Learn about recurrence relations Learn the relationship between sequences and recurrence relations Explore how to solve recurrence relations by iteration Learn about linear homogeneous

More information

Advanced Counting Techniques. Chapter 8

Advanced Counting Techniques. Chapter 8 Advanced Counting Techniques Chapter 8 Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence Relations Nonhomogeneous Recurrence Relations Divide-and-Conquer

More information

CSC2100B Data Structures Analysis

CSC2100B Data Structures Analysis CSC2100B Data Structures Analysis Irwin King king@cse.cuhk.edu.hk http://www.cse.cuhk.edu.hk/~king Department of Computer Science & Engineering The Chinese University of Hong Kong Algorithm An algorithm

More information

Analysis of Algorithm Efficiency. Dr. Yingwu Zhu

Analysis of Algorithm Efficiency. Dr. Yingwu Zhu Analysis of Algorithm Efficiency Dr. Yingwu Zhu Measure Algorithm Efficiency Time efficiency How fast the algorithm runs; amount of time required to accomplish the task Our focus! Space efficiency Amount

More information

1 Examples of Weak Induction

1 Examples of Weak Induction More About Mathematical Induction Mathematical induction is designed for proving that a statement holds for all nonnegative integers (or integers beyond an initial one). Here are some extra examples of

More information

CHAPTER 4 SOME METHODS OF PROOF

CHAPTER 4 SOME METHODS OF PROOF CHAPTER 4 SOME METHODS OF PROOF In all sciences, general theories usually arise from a number of observations. In the experimental sciences, the validity of the theories can only be tested by carefully

More information

CHAPTER 8 Advanced Counting Techniques

CHAPTER 8 Advanced Counting Techniques 96 Chapter 8 Advanced Counting Techniques CHAPTER 8 Advanced Counting Techniques SECTION 8. Applications of Recurrence Relations 2. a) A permutation of a set with n elements consists of a choice of a first

More information

Advanced Counting Techniques. 7.1 Recurrence Relations

Advanced Counting Techniques. 7.1 Recurrence Relations Chapter 7 Advanced Counting Techniques 71 Recurrence Relations We have seen that a recursive definition of a sequence specifies one or more initial terms and a rule for determining subsequent terms from

More information

CS 5321: Advanced Algorithms - Recurrence. Acknowledgement. Outline. Ali Ebnenasir Department of Computer Science Michigan Technological University

CS 5321: Advanced Algorithms - Recurrence. Acknowledgement. Outline. Ali Ebnenasir Department of Computer Science Michigan Technological University CS 5321: Advanced Algorithms - Recurrence Ali Ebnenasir Department of Computer Science Michigan Technological University Acknowledgement Eric Torng Moon Jung Chung Charles Ofria Outline Motivating example:

More information

CS 5321: Advanced Algorithms Analysis Using Recurrence. Acknowledgement. Outline

CS 5321: Advanced Algorithms Analysis Using Recurrence. Acknowledgement. Outline CS 5321: Advanced Algorithms Analysis Using Recurrence Ali Ebnenasir Department of Computer Science Michigan Technological University Acknowledgement Eric Torng Moon Jung Chung Charles Ofria Outline Motivating

More information

1 Recursive Algorithms

1 Recursive Algorithms 400 lecture note #8 [ 5.6-5.8] Recurrence Relations 1 Recursive Algorithms A recursive algorithm is an algorithm which invokes itself. A recursive algorithm looks at a problem backward -- the solution

More information

Advanced Counting Techniques

Advanced Counting Techniques . All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education. Advanced Counting

More information

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska LECTURE 1 INTRODUCTION Course Web Page www.cs.stonybrook.edu/ cse547 The webpage contains: detailed lectures notes slides; very detailed

More information

Divide and Conquer. Recurrence Relations

Divide and Conquer. Recurrence Relations Divide and Conquer Recurrence Relations Divide-and-Conquer Strategy: Break up problem into parts. Solve each part recursively. Combine solutions to sub-problems into overall solution. 2 MergeSort Mergesort.

More information

CS Non-recursive and Recursive Algorithm Analysis

CS Non-recursive and Recursive Algorithm Analysis CS483-04 Non-recursive and Recursive Algorithm Analysis Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 4:30pm - 5:30pm or by appointments lifei@cs.gmu.edu with subject: CS483 http://www.cs.gmu.edu/

More information

Recurrent Problems. ITT9131 Konkreetne Matemaatika. Chapter One The Tower of Hanoi Lines in the Plane The Josephus Problem

Recurrent Problems. ITT9131 Konkreetne Matemaatika. Chapter One The Tower of Hanoi Lines in the Plane The Josephus Problem Recurrent Problems ITT93 Konkreetne Matemaatika Chapter One The Tower of Hanoi Lines in the Plane The Josephus Problem Contents The Tower of Hanoi Lines in the Plane 3 The Josephus Problem 4 Intermezzo:

More information

CS 2210 Discrete Structures Advanced Counting. Fall 2017 Sukumar Ghosh

CS 2210 Discrete Structures Advanced Counting. Fall 2017 Sukumar Ghosh CS 2210 Discrete Structures Advanced Counting Fall 2017 Sukumar Ghosh Compound Interest A person deposits $10,000 in a savings account that yields 10% interest annually. How much will be there in the account

More information

1 Recurrence relations, continued continued

1 Recurrence relations, continued continued 1 Recurrence relations, continued continued Linear homogeneous recurrences are only one of several possible ways to describe a sequence as a recurrence. Here are several other situations which may arise.

More information

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Alessandro Artale UniBZ - http://www.inf.unibz.it/ artale/ SECTION 5.6 Defining Sequences Recursively Copyright Cengage Learning. All rights reserved.

More information

The Principle of Linearity applications in the areas of algebra and analysis

The Principle of Linearity applications in the areas of algebra and analysis Proseminar Mathematisches Problemlösen University of Karlsruhe SS 6 The Principle of Linearity applications in the areas of algebra and analysis Franziska Häfner Contents Converting complex problems into

More information

Appendix G: Mathematical Induction

Appendix G: Mathematical Induction Appendix G: Mathematical Induction Introduction In this appendix, you will study a form of mathematical proof called mathematical induction. To see the logical need for mathematical induction, take another

More information

SOLVING LINEAR RECURRENCE RELATIONS

SOLVING LINEAR RECURRENCE RELATIONS SOLVING LINEAR RECURRENCE RELATIONS Schaum's outline Sec. 6.6 6.9 Rosen Sec. 8.1 8. November 9, 017 margarita.spitsakova@ttu.ee ICY0001: Lecture 8 November 9, 017 1 / 47 Contents 1 Motivation examples

More information

Handout 4: Some Applications of Linear Programming

Handout 4: Some Applications of Linear Programming ENGG 5501: Foundations of Optimization 2018 19 First Term Handout 4: Some Applications of Linear Programming Instructor: Anthony Man Cho So October 15, 2018 1 Introduction The theory of LP has found many

More information

Legendre s Equation. PHYS Southern Illinois University. October 18, 2016

Legendre s Equation. PHYS Southern Illinois University. October 18, 2016 Legendre s Equation PHYS 500 - Southern Illinois University October 18, 2016 PHYS 500 - Southern Illinois University Legendre s Equation October 18, 2016 1 / 11 Legendre s Equation Recall We are trying

More information

Algorithms. Adnan YAZICI Dept. of Computer Engineering Middle East Technical Univ. Ankara - TURKEY. Algorihms, A.Yazici, Fall 2007 CEng 315

Algorithms. Adnan YAZICI Dept. of Computer Engineering Middle East Technical Univ. Ankara - TURKEY. Algorihms, A.Yazici, Fall 2007 CEng 315 Algorithms Adnan YAZICI Dept. of Computer Engineering Middle East Technical Univ. Ankara - TURKEY Algorihms, A.Yazici, Fall 2007 CEng 315 1 Design and Analysis of Algorithms Aspects of studying algorithms:

More information

What you learned in Math 28. Rosa C. Orellana

What you learned in Math 28. Rosa C. Orellana What you learned in Math 28 Rosa C. Orellana Chapter 1 - Basic Counting Techniques Sum Principle If we have a partition of a finite set S, then the size of S is the sum of the sizes of the blocks of the

More information

Electrical Engineering and Computer Science Department The University of Toledo Toledo, OH 43606

Electrical Engineering and Computer Science Department The University of Toledo Toledo, OH 43606 Gursel Serpen and David L. Livingston Electrical Engineering and Computer Science Department The University of Toledo Toledo, OH 43606 ANNIE 98 PRESENTATION THE RESEARCH WORK A higher-order single-layer

More information

Recurrence Relations

Recurrence Relations Recurrence Relations Winter 2017 Recurrence Relations Recurrence Relations A recurrence relation for the sequence {a n } is an equation that expresses a n in terms of one or more of the previous terms

More information

Exam 2 Solutions. x 1 x. x 4 The generating function for the problem is the fourth power of this, (1 x). 4

Exam 2 Solutions. x 1 x. x 4 The generating function for the problem is the fourth power of this, (1 x). 4 Math 5366 Fall 015 Exam Solutions 1. (0 points) Find the appropriate generating function (in closed form) for each of the following problems. Do not find the coefficient of x n. (a) In how many ways can

More information

6.042/18.062J Mathematics for Computer Science March 17, 2005 Srini Devadas and Eric Lehman. Recurrences

6.042/18.062J Mathematics for Computer Science March 17, 2005 Srini Devadas and Eric Lehman. Recurrences 6.04/8.06J Mathematics for Computer Science March 7, 00 Srini Devadas and Eric Lehman Lecture Notes Recurrences Recursion breaking an object down into smaller objects of the same type is a major theme

More information

Logic Programming. Prolog : 3

Logic Programming. Prolog : 3 Logic Programming Prolog : 3 Review We don't write normal functions in Prolog. Instead we relate the input and the output e.g. factorial: factorial(0, 1). factorial(n, V) : N > 0, N1 is N 1, factorial(n1,

More information

Applications. More Counting Problems. Complexity of Algorithms

Applications. More Counting Problems. Complexity of Algorithms Recurrences Applications More Counting Problems Complexity of Algorithms Part I Recurrences and Binomial Coefficients Paths in a Triangle P(0, 0) P(1, 0) P(1,1) P(2, 0) P(2,1) P(2, 2) P(3, 0) P(3,1) P(3,

More information

Discrete Mathematics. Kishore Kothapalli

Discrete Mathematics. Kishore Kothapalli Discrete Mathematics Kishore Kothapalli 2 Chapter 4 Advanced Counting Techniques In the previous chapter we studied various techniques for counting and enumeration. However, there are several interesting

More information

Notes for Recitation 14

Notes for Recitation 14 6.04/18.06J Mathematics for Computer Science October 4, 006 Tom Leighton and Marten van Dijk Notes for Recitation 14 1 The Akra-Bazzi Theorem Theorem 1 (Akra-Bazzi, strong form). Suppose that: is defined

More information

5. Sequences & Recursion

5. Sequences & Recursion 5. Sequences & Recursion Terence Sim 1 / 42 A mathematician, like a painter or poet, is a maker of patterns. Reading Sections 5.1 5.4, 5.6 5.8 of Epp. Section 2.10 of Campbell. Godfrey Harold Hardy, 1877

More information

Topics in Algorithms. 1 Generation of Basic Combinatorial Objects. Exercises. 1.1 Generation of Subsets. 1. Consider the sum:

Topics in Algorithms. 1 Generation of Basic Combinatorial Objects. Exercises. 1.1 Generation of Subsets. 1. Consider the sum: Topics in Algorithms Exercises 1 Generation of Basic Combinatorial Objects 1.1 Generation of Subsets 1. Consider the sum: (ε 1,...,ε n) {0,1} n f(ε 1,..., ε n ) (a) Show that it may be calculated in O(n)

More information

Chapter 8: Recursion. March 10, 2008

Chapter 8: Recursion. March 10, 2008 Chapter 8: Recursion March 10, 2008 Outline 1 8.1 Recursively Defined Sequences 2 8.2 Solving Recurrence Relations by Iteration 3 8.4 General Recursive Definitions Recursively Defined Sequences As mentioned

More information

Chapter 2. Mathematical Reasoning. 2.1 Mathematical Models

Chapter 2. Mathematical Reasoning. 2.1 Mathematical Models Contents Mathematical Reasoning 3.1 Mathematical Models........................... 3. Mathematical Proof............................ 4..1 Structure of Proofs........................ 4.. Direct Method..........................

More information

Analysis of Algorithms Generating Functions II. Holger Findling

Analysis of Algorithms Generating Functions II. Holger Findling Generating Functions II Holger Findling Lecture notes are obtained from Fundamentals of Algorithmics, Gilles Brassard and Paul Bratley. Inhomogeneous Recurrences. The solution of a linear recurrence with

More information

Recurrences COMP 215

Recurrences COMP 215 Recurrences COMP 215 Analysis of Iterative Algorithms //return the location of the item matching x, or 0 if //no such item is found. index SequentialSearch(keytype[] S, in, keytype x) { index location

More information

Discrete Mathematics -- Chapter 10: Recurrence Relations

Discrete Mathematics -- Chapter 10: Recurrence Relations Discrete Mathematics -- Chapter 10: Recurrence Relations Hung-Yu Kao ( 高宏宇 ) Department of Computer Science and Information Engineering, National Cheng Kung University First glance at recurrence F n+2

More information

Recursion and Induction

Recursion and Induction Recursion and Induction Themes Recursion Recursive Definitions Recurrence Relations Induction (prove properties of recursive programs and objects defined recursively) Examples Tower of Hanoi Gray Codes

More information

Recursion and Induction

Recursion and Induction Recursion and Induction Themes Recursion Recursive Definitions Recurrence Relations Induction (prove properties of recursive programs and objects defined recursively) Examples Tower of Hanoi Gray Codes

More information

MEETING 9 - INDUCTION AND RECURSION

MEETING 9 - INDUCTION AND RECURSION MEETING 9 - INDUCTION AND RECURSION We do some initial Peer Instruction... Predicates Before we get into mathematical induction we will repeat the concept of a predicate. A predicate is a mathematical

More information

Why do we need math in a data structures course?

Why do we need math in a data structures course? Math Review 1 Why do we need math in a data structures course? To nalyze data structures and algorithms Deriving formulae for time and memory requirements Will the solution scale? Quantify the results

More information

Outline. We will cover (over the next few weeks) Induction Strong Induction Constructive Induction Structural Induction

Outline. We will cover (over the next few weeks) Induction Strong Induction Constructive Induction Structural Induction Outline We will cover (over the next few weeks) Induction Strong Induction Constructive Induction Structural Induction Induction P(1) ( n 2)[P(n 1) P(n)] ( n 1)[P(n)] Why Does This Work? I P(1) ( n 2)[P(n

More information

CSI2101-W08- Recurrence Relations

CSI2101-W08- Recurrence Relations Motivation CSI2101-W08- Recurrence Relations where do they come from modeling program analysis Solving Recurrence Relations by iteration arithmetic/geometric sequences linear homogenous recurrence relations

More information

Chapter 5.2: Series solution near an ordinary point

Chapter 5.2: Series solution near an ordinary point Chapter 5.2: Series solution near an ordinary point We now look at ODE s with polynomial coefficients of the form: P (x)y + Q(x)y + R(x)y = 0. Thus, we assume P (x), Q(x), R(x) are polynomials in x. Why?

More information

Section 8.2 : Homogeneous Linear Systems

Section 8.2 : Homogeneous Linear Systems Section 8.2 : Homogeneous Linear Systems Review: Eigenvalues and Eigenvectors Let A be an n n matrix with constant real components a ij. An eigenvector of A is a nonzero n 1 column vector v such that Av

More information

Power Series Solutions We use power series to solve second order differential equations

Power Series Solutions We use power series to solve second order differential equations Objectives Power Series Solutions We use power series to solve second order differential equations We use power series expansions to find solutions to second order, linear, variable coefficient equations

More information

Binomial Coefficient Identities/Complements

Binomial Coefficient Identities/Complements Binomial Coefficient Identities/Complements CSE21 Fall 2017, Day 4 Oct 6, 2017 https://sites.google.com/a/eng.ucsd.edu/cse21-fall-2017-miles-jones/ permutation P(n,r) = n(n-1) (n-2) (n-r+1) = Terminology

More information

LINEAR RECURSIVE SEQUENCES. The numbers in the sequence are called its terms. The general form of a sequence is

LINEAR RECURSIVE SEQUENCES. The numbers in the sequence are called its terms. The general form of a sequence is LINEAR RECURSIVE SEQUENCES BJORN POONEN 1. Sequences A sequence is an infinite list of numbers, like 1) 1, 2, 4, 8, 16, 32,.... The numbers in the sequence are called its terms. The general form of a sequence

More information

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency Lecture 2 Fundamentals of the Analysis of Algorithm Efficiency 1 Lecture Contents 1. Analysis Framework 2. Asymptotic Notations and Basic Efficiency Classes 3. Mathematical Analysis of Nonrecursive Algorithms

More information

Data Structures and Algorithms CMPSC 465

Data Structures and Algorithms CMPSC 465 Data Structures and Algorithms CMPSC 465 LECTURE 9 Solving recurrences Substitution method Adam Smith S. Raskhodnikova and A. Smith; based on slides by E. Demaine and C. Leiserson Review question Draw

More information

CS 5114: Theory of Algorithms. Tractable Problems. Tractable Problems (cont) Decision Problems. Clifford A. Shaffer. Spring 2014

CS 5114: Theory of Algorithms. Tractable Problems. Tractable Problems (cont) Decision Problems. Clifford A. Shaffer. Spring 2014 Department of Computer Science Virginia Tech Blacksburg, Virginia Copyright c 2014 by Clifford A. Shaffer : Theory of Algorithms Title page : Theory of Algorithms Clifford A. Shaffer Spring 2014 Clifford

More information

Another Proof By Contradiction: 2 is Irrational

Another Proof By Contradiction: 2 is Irrational Another Proof By Contradiction: 2 is Irrational Theorem: 2 is irrational. Proof: By contradiction. Suppose 2 is rational. Then 2 = a/b for some a, b N +. We can assume that a/b is in lowest terms. Therefore,

More information

Design Patterns for Data Structures. Chapter 3. Recursive Algorithms

Design Patterns for Data Structures. Chapter 3. Recursive Algorithms Chapter 3 Recursive Algorithms Writing recurrences + Writing recurrences To determine the statement execution count is a two-step problem. Write down the recurrence from the recursive code for the algorithm.

More information

Lecture 12 : Recurrences DRAFT

Lecture 12 : Recurrences DRAFT CS/Math 240: Introduction to Discrete Mathematics 3/1/2011 Lecture 12 : Recurrences Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last few classes we talked about program correctness. We

More information

Solving Recurrences. 1. Express the running time (or use of some other resource) as a recurrence.

Solving Recurrences. 1. Express the running time (or use of some other resource) as a recurrence. Solving Recurrences Recurrences and Recursive Code Many (perhaps most) recursive algorithms fall into one of two categories: tail recursion and divide-andconquer recursion. We would like to develop some

More information

On generalized Frame-Stewart numbers

On generalized Frame-Stewart numbers On generalized Frame-Stewart numbers Jonathan Chappelon and Akihiro Matsuura August 31, 2010 Abstract For the multi-peg Tower of Hanoi problem with k 4 pegs, so far the best solution is obtained by the

More information

COMP 555 Bioalgorithms. Fall Lecture 3: Algorithms and Complexity

COMP 555 Bioalgorithms. Fall Lecture 3: Algorithms and Complexity COMP 555 Bioalgorithms Fall 2014 Lecture 3: Algorithms and Complexity Study Chapter 2.1-2.8 Topics Algorithms Correctness Complexity Some algorithm design strategies Exhaustive Greedy Recursion Asymptotic

More information

arxiv: v1 [math.ds] 24 Jul 2011

arxiv: v1 [math.ds] 24 Jul 2011 Simple Spectrum for Tensor Products of Mixing Map Powers V.V. Ryzhikov arxiv:1107.4745v1 [math.ds] 24 Jul 2011 1 Introduction June 28, 2018 In this note we consider measure-preserving transformations of

More information

Affine Dynamic Logic

Affine Dynamic Logic Affine Dynamic Logic Sree Vishant Prabhakaran sreevisp@andrew.cmu.edu May 9, 2017 1 Abstract dl as we have seen in class is one of many dynamic multimodal logic systems used to model and prove statements

More information

Math 116 Practice for Exam 3

Math 116 Practice for Exam 3 Math 6 Practice for Eam 3 Generated December, 6 Name: SOLUTIONS Instructor: Section Number:. This eam has 6 questions. Note that the problems are not of equal difficulty, so you may want to skip over and

More information

T. Liggett Mathematics 171 Final Exam June 8, 2011

T. Liggett Mathematics 171 Final Exam June 8, 2011 T. Liggett Mathematics 171 Final Exam June 8, 2011 1. The continuous time renewal chain X t has state space S = {0, 1, 2,...} and transition rates (i.e., Q matrix) given by q(n, n 1) = δ n and q(0, n)

More information

Solution/Correction standard, second Test Mathematics A + B1; November 7, 2014.

Solution/Correction standard, second Test Mathematics A + B1; November 7, 2014. Solution/Correction standard, second Test Mathematics A + B1; November 7, 014. Kenmerk : Leibniz/toetsen/Re-Exam-Math-A-B1-141-Solutions Course : Mathematics A + B1 (Leibniz) Vakcode : 1911010 Date : November

More information

Intermediate Math Circles March 11, 2009 Sequences and Series

Intermediate Math Circles March 11, 2009 Sequences and Series 1 University of Waterloo Faculty of Mathematics Centre for Education in Mathematics and Computing Intermediate Math Circles March 11, 009 Sequences and Series Tower of Hanoi The Tower of Hanoi is a game

More information

Grade 11/12 Math Circles Fall Nov. 5 Recurrences, Part 2

Grade 11/12 Math Circles Fall Nov. 5 Recurrences, Part 2 1 Faculty of Mathematics Waterloo, Ontario Centre for Education in Mathematics and Computing Grade 11/12 Math Circles Fall 2014 - Nov. 5 Recurrences, Part 2 Running time of algorithms In computer science,

More information

17 Advancement Operator Equations

17 Advancement Operator Equations November 14, 2017 17 Advancement Operator Equations William T. Trotter trotter@math.gatech.edu Review of Recurrence Equations (1) Problem Let r(n) denote the number of regions determined by n lines that

More information

CDM. Recurrences and Fibonacci

CDM. Recurrences and Fibonacci CDM Recurrences and Fibonacci Klaus Sutner Carnegie Mellon University 20-fibonacci 2017/12/15 23:16 1 Recurrence Equations Second Order The Fibonacci Monoid Recurrence Equations 3 We can define a sequence

More information

Section 5.2 Solving Recurrence Relations

Section 5.2 Solving Recurrence Relations Section 5.2 Solving Recurrence Relations If a g(n) = f (a g(0),a g(1),..., a g(n 1) ) find a closed form or an expression for a g(n). Recall: nth degree polynomials have n roots: a n x n + a n 1 x n 1

More information

CDM. Recurrences and Fibonacci. 20-fibonacci 2017/12/15 23:16. Terminology 4. Recurrence Equations 3. Solution and Asymptotics 6.

CDM. Recurrences and Fibonacci. 20-fibonacci 2017/12/15 23:16. Terminology 4. Recurrence Equations 3. Solution and Asymptotics 6. CDM Recurrences and Fibonacci 1 Recurrence Equations Klaus Sutner Carnegie Mellon University Second Order 20-fibonacci 2017/12/15 23:16 The Fibonacci Monoid Recurrence Equations 3 Terminology 4 We can

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 10:

CMSC 132, Object-Oriented Programming II Summer Lecture 10: CMSC 132, Object-Oriented Programming II Summer 2016 Lecturer: Anwar Mamat Lecture 10: Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 10.1 RECURSION

More information

Solutions. Problem 1: Suppose a polynomial in n of degree d has the form

Solutions. Problem 1: Suppose a polynomial in n of degree d has the form Assignment 1 1. Problem 3-1 on p. 57 2. Problem 3-2 on p. 58 3. Problem 4-5 on p. 86 4. Problem 6-1 on p. 142 5. Problem 7-4 on p. 162 6. Prove correctness (including halting) of SelectionSort (use loop

More information

Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University

Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University U Kang 1 In This Lecture Set concepts and notation Logarithms Summations Recurrence Relations Recursion Induction Proofs

More information

Solving Recurrences. 1. Express the running time (or use of some other resource) as a recurrence.

Solving Recurrences. 1. Express the running time (or use of some other resource) as a recurrence. 1 Recurrences and Recursive Code Solving Recurrences Many (perhaps most) recursive algorithms fall into one of two categories: tail recursion and divide-andconquer recursion. We would like to develop some

More information

Recurrence Relations. fib(0) = 1 fib(1) = 1 q(0) = 1

Recurrence Relations. fib(0) = 1 fib(1) = 1 q(0) = 1 Recurrence Relations Reading: Gossett Sections 7.1 and 7.. Definition: Aone-wayinfinite sequence is a function from the natural numbers to some other set. E.g. fib(0) = 1, fib(1) = 1, fib() =,fib(3) =

More information

First and Second Order ODEs

First and Second Order ODEs Civil Engineering 2 Mathematics Autumn 211 M. Ottobre First and Second Order ODEs Warning: all the handouts that I will provide during the course are in no way exhaustive, they are just short recaps. Notation

More information

V. Adamchik 1. Recurrences. Victor Adamchik Fall of 2005

V. Adamchik 1. Recurrences. Victor Adamchik Fall of 2005 V. Adamchi Recurrences Victor Adamchi Fall of 00 Plan Multiple roots. More on multiple roots. Inhomogeneous equations 3. Divide-and-conquer recurrences In the previous lecture we have showed that if the

More information

CS1802 Optional Recitation Week 11-12: Series, Induction, Recurrences

CS1802 Optional Recitation Week 11-12: Series, Induction, Recurrences CS1802 Discrete Structures Recitation Fall 2017 Nov 19 - November 26, 2017 CS1802 Optional Recitation Week 11-12: Series, Induction, Recurrences 1 Sequences, Series and Recurrences PB 1. Prove that n k=0

More information

Eigenvalues and Eigenvectors

Eigenvalues and Eigenvectors Contents Eigenvalues and Eigenvectors. Basic Concepts. Applications of Eigenvalues and Eigenvectors 8.3 Repeated Eigenvalues and Symmetric Matrices 3.4 Numerical Determination of Eigenvalues and Eigenvectors

More information

A SUMMARY OF RECURSION SOLVING TECHNIQUES

A SUMMARY OF RECURSION SOLVING TECHNIQUES A SUMMARY OF RECURSION SOLVING TECHNIQUES KIMMO ERIKSSON, KTH These notes are meant to be a complement to the material on recursion solving techniques in the textbook Discrete Mathematics by Biggs. In

More information

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK UNIT-I SUB NAME: DESIGN AND ANALYSIS OF ALGORITHMS. PART A (2 Marks)

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK UNIT-I SUB NAME: DESIGN AND ANALYSIS OF ALGORITHMS. PART A (2 Marks) DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK UNIT-I SUB CODE: CS2251 DEPT: CSE SUB NAME: DESIGN AND ANALYSIS OF ALGORITHMS SEM/YEAR: III/ II PART A (2 Marks) 1. Compare the order of growth

More information

Recursion: Introduction and Correctness

Recursion: Introduction and Correctness Recursion: Introduction and Correctness CSE21 Winter 2017, Day 7 (B00), Day 4-5 (A00) January 25, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Today s Plan From last time: intersecting sorted lists and

More information

CSL105: Discrete Mathematical Structures. Ragesh Jaiswal, CSE, IIT Delhi

CSL105: Discrete Mathematical Structures. Ragesh Jaiswal, CSE, IIT Delhi Definition (Linear homogeneous recurrence) A linear homogeneous recurrence relation of degree k with constant coefficients is a recurrence relation of the form a n = c 1 a n 1 + c 2 a n 2 +... + c k a

More information

Computing generating functions for the number of descents in permutations which avoid a family of permutations that start with 1

Computing generating functions for the number of descents in permutations which avoid a family of permutations that start with 1 Computing generating functions for the number of descents in permutations which avoid a family of permutations that start with 1 Quang T. Bach Department of Mathematics University of California, San Diego

More information

Lesson 8. Homework Problem Set Sample Solutions. 1. r = p = x = n = x = m = x = n =

Lesson 8. Homework Problem Set Sample Solutions. 1. r = p = x = n = x = m = x = n = Homework Problem Set Sample Solutions 1. r = 2 2. p = - 12 3. x = 4 4. n = -2 5. x = 2 6. m = -1 7. x = 1 8. n = 10 9. v = 2 10. v = 10 Unit 3: Solving Equations & Inequalities 107 11. b = -1 12. n = 0

More information

An Outline of Some Basic Theorems on Infinite Series

An Outline of Some Basic Theorems on Infinite Series An Outline of Some Basic Theorems on Infinite Series I. Introduction In class, we will be discussing the fact that well-behaved functions can be expressed as infinite sums or infinite polynomials. For

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms CS245-2015S-23 NP-Completeness and Undecidablity David Galles Department of Computer Science University of San Francisco 23-0: Hard Problems Some algorithms take exponential

More information

CS 147: Computer Systems Performance Analysis

CS 147: Computer Systems Performance Analysis CS 147: Computer Systems Performance Analysis Advanced Regression Techniques CS 147: Computer Systems Performance Analysis Advanced Regression Techniques 1 / 31 Overview Overview Overview Common Transformations

More information

Chapter Finding parse trees

Chapter Finding parse trees Chapter 16 NP Some tasks definitely require exponential time. That is, we can not only display an exponential-time algorithm, but we can also prove that the problem cannot be solved in anything less than

More information