Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2.5 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,

Slides:



Advertisements
Similar presentations
Week 6 - Wednesday CS322.
Advertisements

Appendix B Solving Recurrence Equations : With Applications to Analysis of Recursive Algorithms.
Algorithms Recurrences. Definition – a recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs Example.
Induction and recursion
Recurrence Relations Reading Material –Chapter 2 as a whole, but in particular Section 2.8 –Chapter 4 from Cormen’s Book.
Ch 5.2: Series Solutions Near an Ordinary Point, Part I
Recursive Definitions Rosen, 3.4. Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
1 Recursion, Recurrences and Induction Supplementary Notes Prepared by Raymond Wong Presented by Raymond Wong.
Recurrence Relations Reading Material –Chapter 2 as a whole, but in particular Section 2.8 –Chapter 4 from Cormen’s Book.
Discrete Structures Chapter 5: Sequences, Mathematical Induction, and Recursion 5.7 Solving Recurrence Relations by Iteration The keener one’s sense of.
Set, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides.
Discrete Structures Chapter 5: Sequences, Mathematical Induction, and Recursion 5.2 Mathematical Induction I [Mathematical induction is] the standard proof.
Proofs, Recursion, and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Recurrence Relations Connection to recursive algorithms Techniques for solving them.
Induction and Recursion by: Mohsin tahir (GL) Numan-ul-haq Waqas akram Rao arslan Ali asghar.
Induction and recursion
Analysis of Recursive Algorithms October 29, 2014
1 Linear Recurrence Relations Part I Jorge Cobb The University of Texas at Dallas.
Applied Discrete Mathematics Week 9: Relations
Honors Geometry Section 1.0 Patterns and Inductive Reasoning
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.
Induction and recursion
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.
Copyright © Cengage Learning. All rights reserved.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Analysis of Algorithms
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Chapter 4: Induction and Recursion
1 Recurrences Algorithms Jay Urbain, PhD Credits: Discrete Mathematics and Its Applications, by Kenneth Rosen The Design and Analysis of.
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.
1 Section 5.5 Solving Recurrences Any recursively defined function ƒ with domain N that computes numbers is called a recurrence or recurrence relation.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
DR. NAVEED AHMAD DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF PESHAWAR LECTURE-5 Advance Algorithm Analysis.
1 Put your name if you want your attendance credit. Please put your as well. CSC 320 is done at 11:30 so I did NOT fill in the box for 11:30 for.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 3.
Introduction to Algorithms Chapter 4: Recurrences.
Foundations of Discrete Mathematics Chapters 5 By Dr. Dalia M. Gil, Ph.D.
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.
CSE 2813 Discrete Structures Solving Recurrence Relations Section 6.2.
Foundations II: Data Structures and Algorithms
COMP 170 L2 L11: Recursion, Recurrence, and Induction l Objective n Recursion  A problem solving technique that reduces big problems into smaller ones.
1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS.
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.
1 2/21/2016 MATH 224 – Discrete Mathematics Sequences and Sums A sequence of the form ar 0, ar 1, ar 2, ar 3, ar 4, …, ar n, is called a geometric sequence.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
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 we can reach a particular.
Solving Linear Homogeneous Recurrence Relations ICS 6D Sandy Irani.
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.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
Recursive Definitions
Analysis of Algorithms CS 477/677
Proofs, Recursion and Analysis of Algorithms
Induction and recursion
Design and Analysis of Algorithms
Lecture Outline for Recurrences
Proofs, Recursion and Analysis of Algorithms
ICS 353: Design and Analysis of Algorithms
Copyright © Cengage Learning. All rights reserved.
Mathematical Induction
Mathematical Induction
Copyright © Cengage Learning. All rights reserved.
Mathematical Induction
ICS 353: Design and Analysis of Algorithms
Copyright © Cengage Learning. All rights reserved.
Presentation transcript:

Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2.5 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs, Recursion and Analysis of Algorithms

Solving Recurrence Relations Example 29 defined a recurrence relation S(1) = 2 Eq(1) S(n) =2S(n – 1) for n >= 2 Eq(2) We can recognize S as the sequence 2, 4, 8, 16,... which can also be written as S(n) = 2 n. Eq(3) If we want to compute S(10) we can do so directly using the second definition, instead of having to compute S(2), S(3), … Equation 3 is an example of what is called a closed- form solution to the recurrence relation. Finding a closed form-solution is called solving the recurrence relation. Section 2.5Recurrence Relations1

Section 2.5Recurrence Relations2 Expand, guess and verify One way to solve: so-called “expand, guess, and verify” approach, where we “expand” the sequence by generating several terms using the recurrence relation “guess” at a closed form solution by looking at the terms in the sequence and detecting a pattern “verify” the solution by actually proving that it is correct. Expand by working backwards: S(n), S(n - 1), S(n - 2), …, S(1). In general there will be k expansions, where k = n – 1.

Section 2.5Recurrence Relations3 Expand, guess and verify: Example Show that S(n) = 2 n for the following recurrence relation: S(1) = 1 S(n) = 2S(n-1) for n  2 Expansion: Using the recurrence relation over again everytime S(n) = 2S(n-1)  S(n) = 2(2S(n-2)) = 2 2 S( n -2)  S(n) = 2 2 (2S(n-3)) = 2 3 S( n -3) Looking at the developing pattern, we guess that after k such expansions, the equation has the form S(n) = 2 k S(n-k) This should stop when n-k =1, hence k = n-1, S(n) = 2 n-1 S(1)  S(n) = 2.2 n-1 = 2 n At this point we have a conjecture, it still must be proven.

Section 2.5Recurrence Relations4 Verification Step for Expand, Guess & Verify Confirm derived closed-form solution by induction on the value of n. In other words, prove that S(n) = 2.2 n-1 = 2 n Basis step, S(l) = 2 = 2 1. True, by definition. Now, assume that S(k) = 2 k. Then S(k+1) = 2S(k) (by using the recurrence relation definition) S(k+1) = 2(2 k ) (by using the above inductive hypothesis)  S(k+1) = 2 k+1 This proves that our closed-form solution is correct.

Section 2.5Recurrence Relations5 Properties of recurrence relations A recurrence relation is linear if it can be written as S(n) = f 1 (n)S(n-1) + f 2 (n)S(n-2) + …..+ f k (n)S(n-k) + g(n) The term linear means that each term of the sequence is defined as a linear function of the preceding terms; i.e., all the S(i) as shown above have power 1. Example: F(n) = F(n-1) + F(n-2) In general, the f i ’s can be expressions involving n. The relation is homogeneous if g(n) = 0 for all n.

Section 2.5Recurrence Relations6 Order of Recurrence Relation A recurrence relation is said to have constant coefficients if the f’s are all constants. Fibonaci relation is homogenous and linear: F(n) = F(n-1) + F(n-2) Non-constant coefficients: T(n) = 2nT(n-1) + 3n 2 T(n-2) Order of a relation is defined by the number of previous terms in a relation for the n th term. First order: S(n) = 2S(n-1) n th term depends only on term n-1 Second order: F(n) = F(n-1) + F(n-2) n th term depends only on term n-1 and n-2 Third Order: T(n) = 3nT(n-2) + 2T(n-1) + T(n-3) n th term depends only on term n-1 and n-2 and n-3

Section 2.5Recurrence Relations7 Solving Recurrence Relations Equation 8, page 150 is a formula that can be used to solve closed-form solutions for linear, first-order recurrence relations with constant coefficients. Table 2.6 on page 151 describes the EGV method of developing a conjectured solution and then explains how to use the solution formula to verify the conjecture. (Assuming, of course, that it’s correct.)

Section 2.5Recurrence Relations8 Properties of recurrence relations A nonlinear relation is the one that has earlier values in the definition as powers other than 1. Example: F(n+1) = 2nF(n-1)(1-F(n-1)) Solutions are quite complex. Homogenous relation is a relation that has g(n) = 0 for all n Example: a(n) – a(n-1) = 2n Inhomogenous relation: Example: S(n) = 2S(n-1)