Recurrence Relations Reading Material –Chapter 2 as a whole, but in particular Section 2.8 –Chapter 4 from Cormen’s Book.

Slides:



Advertisements
Similar presentations
A simple example finding the maximum of a set S of n numbers.
Advertisements

5/5/20151 Analysis of Algorithms Lecture 6&7: Master theorem and substitution method.
Appendix B Solving Recurrence Equations : With Applications to Analysis of Recursive Algorithms.
Comp 122, Spring 2004 Divide and Conquer (Merge Sort)
Divide-and-Conquer Recursive in structure –Divide the problem into several smaller sub-problems that are similar to the original but smaller in size –Conquer.
Algorithm : Design & Analysis [4]
11 Computer Algorithms Lecture 6 Recurrence Ch. 4 (till Master Theorem) Some of these slides are courtesy of D. Plaisted et al, UNC and M. Nicolescu, UNR.
Algorithms Recurrences. Definition – a recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs Example.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
CSE115/ENGR160 Discrete Mathematics 04/19/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.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
Ch 2.1: Linear Equations; Method of Integrating Factors
Recurrence Relations Reading Material –Chapter 2 as a whole, but in particular Section 2.8 –Chapter 4 from Cormen’s Book.
Recurrences Part 3. Recursive Algorithms Recurrences are useful for analyzing recursive algorithms Recurrence – an equation or inequality that describes.
Recurrences The expression: is a recurrence. –Recurrence: an equation that describes a function in terms of its value on smaller functions Analysis of.
Recurrence Relations Connection to recursive algorithms Techniques for solving them.
1Chapter 2. 2 Example 3Chapter 2 4 EXAMPLE 5Chapter 2.
1 Topic The Substitution Method. 2 Topic The Substitution Method California Standard: 9.0 Students solve a system of two linear equations.
Recurrences The expression: is a recurrence. –Recurrence: an equation that describes a function in terms of its value on smaller functions BIL741: Advanced.
Applied Discrete Mathematics Week 9: Relations
Introduction to Algorithms Jiafen Liu Sept
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Analysis of Algorithms
Analyzing Recursive Algorithms A recursive algorithm can often be described by a recurrence equation that describes the overall runtime on a problem of.
The importance of sequences and infinite series in calculus stems from Newton’s idea of representing functions as sums of infinite series.  For instance,
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
1 Computer Algorithms Lecture 7 Master Theorem Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR.
Project 2 due … Project 2 due … Project 2 Project 2.
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2.5 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
Module #17: Recurrence Relations Rosen 5 th ed., §
Chapter 2 Mathematical preliminaries 2.1 Set, Relation and Functions 2.2 Proof Methods 2.3 Logarithms 2.4 Floor and Ceiling Functions 2.5 Factorial and.
DR. NAVEED AHMAD DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF PESHAWAR LECTURE-5 Advance Algorithm Analysis.
10/25/20151 CS 3343: Analysis of Algorithms Lecture 6&7: Master theorem and substitution method.
Chapter 8 With Question/Answer Animations. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Chapter 4. Recurrences. Outline Offers three methods for solving recurrences, that is for obtaining asymptotic bounds on the solution In the substitution.
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
7.2 Solving Linear Recurrence Relations Some of these recurrence relations can be solved using iteration or some other ad hoc technique. However, one important.
Asymptotics and Recurrence Equations Prepared by John Reif, Ph.D. Analysis of Algorithms.
CSE 2813 Discrete Structures Solving Recurrence Relations Section 6.2.
Recurrences – II. Comp 122, Spring 2004.
ADVANCED ALGORITHMS REVIEW OF ANALYSIS TECHNIQUES (UNIT-1)
1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method.
Introduction to Algorithms (2 nd edition) by Cormen, Leiserson, Rivest & Stein Chapter 4: Recurrences.
Section 3.5 Solving Systems of Linear Equations in Two Variables by the Addition Method.
Divide and Conquer Faculty Name: Ruhi Fatima Topics Covered Divide and Conquer Matrix multiplication Recurrence.
Binomial Coefficients and Identities
Mathematical Analysis of Recursive Algorithm CSG3F3 Lecture 7.
Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar Dr Nazir A. Zafar Advanced Algorithms Analysis and Design.
1 Lecture Outline for Recurrences Already Covered: Recursive definition of sequences Recursive definition of sets Recursive definition of operations Recursive.
Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar Dr Nazir A. Zafar Advanced Algorithms Analysis and Design.
CSG523/ Desain dan Analisis Algoritma
CSG523/ Desain dan Analisis Algoritma
Equal costs at all levels
Modeling with Recurrence Relations
Proofs, Recursion and Analysis of Algorithms
Lecture 11. Master Theorem for analyzing Recursive relations
Chapter 4: Divide and Conquer
Design and Analysis of Algorithms
CS 3343: Analysis of Algorithms
ICS 353: Design and Analysis of Algorithms
Solving Recurrence Relations
Divide and Conquer (Merge Sort)
Analysis of Algorithms
At the end of this session, learner will be able to:
Recurrence Relations Discrete Structures.
ICS 353: Design and Analysis of Algorithms
Presentation transcript:

Recurrence Relations Reading Material –Chapter 2 as a whole, but in particular Section 2.8 –Chapter 4 from Cormen’s Book.

Recurrence Relations Objective: To discuss techniques for solving recurrence relations. –These techniques will be very important and “handy” tools for analyzing algorithms that are recursive. Linear Homogenous Recurrences –Characteristic Equations Inhomogeneous Recurrences –The Master Theorem –Recurrence Expansion –The Substitution Method –The Change of Variable Method

Linear Homogeneous Equations Definition: A recurrence relation is called linear homogeneous with constant coefficients if it is of the form: We restrict our discussion to homogeneous recurrence equations with k=1 or k=2

Solution of Linear Homogeneous Equations When k=1, and hence the solution is When k=2, the following steps are followed to solve the recurrence: –Find r 1 and r 2, the solutions to the characteristic equation –If r 1 = r 2 = r, then Otherwise –Determine c 1 and c 2 from the initial values f(n 0 ) and f(n 0 +1)

Examples

Inhomogeneous Equations Definition: A recurrence relation is called inhomogeneous if it is not a homogeneous recurrence relation. In particular, we will look at where  i 1  i  k  g i (n) is not a constant or g 0 (n)  0.

Solution for Inhomogeneous Recurrences No general method for solving inhomogeneous recurrences exists. However, –There are cases where a formula for a class of inhomogeneous recurrence relations exists (Master Theorem) –The rest depend on experience and/or trial and error in choosing one of the following techniques Expansion Substitution Change of variable

Master Theorem Theorem: Let a  1 and b>1 be constants, let g(n) be a function, and let f(n) be defined on the nonnegative integers by the recurrence where we interpret n/b to mean either  n/b  or  n/b . Then f(n) can be bounded asymptotically as follows –If  >0  g(n)=O(n log b a -  ), then f(n) =  (n log b a ). –If g(n)=  (n log b a ), then f(n) =  (n log b a log n). –If  >0  g(n)=  (n log b a +  ), and if  c n 0, then f(n) =  (g(n)).

Examples

Gaps in the Master Theorem The three cases in the theorem do not cover all the possibilities for g(n). There are gaps between cases 1 and 2, and 2 and 3. –For example, can we apply the Master theorem on the following recurrence?

The Expansion Method When expanding few terms of some recurrences, a solution may become more apparent. Example: Consider the previous recurrence

The Substitution Method If we can have a “good” guess of what the answer may be, then we can use mathematical induction to prove that it is correct. Example: Consider the following recurrence: This recurrence seems similar to (when n is a power of 2, they are exactly equal.) By applying case 2 of the master theorem, the solution to the second recurrence is  (nlog n). Therefore, we can guess that we can find c,d > 0  dnlog n  f(n)=2f(  n/2  ) + n  cnlog n for all values of n.

Example (Cont.) We show by induction that f(n)  cnlog n. The other inequality is left as an exercise. –Induction Step –Initial Step

The Change of Variables Method The idea is to change the domain of the function and define a new recurrence in the new domain whose solution may be easier to obtain or is already known. Once the solution is obtained, we convert the domain of the function back to its original domain.

Example