1 CSE 20 Lecture 13: Analysis of Recursive Functions CK Cheng.

Slides:



Advertisements
Similar presentations
Appendix B Solving Recurrence Equations : With Applications to Analysis of Recursive Algorithms.
Advertisements

Algorithm : Design & Analysis [4]
CS 2210 (22C:19) Discrete Structures Advanced Counting
Recursion Sections 7.1 and 7.2 of Rosen Fall 2008 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions:
Discrete Structures Chapter 6 Recurrence Relations
Analysis of Recursive Algorithms
1 CSE 20 Lecture 12: Analysis of Homogeneous Linear Recursion CK Cheng May 5, 2011.
Expressing Sequences Explicitly By: Matt Connor Fall 2013.
Applied Discrete Mathematics Week 9: Relations
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Mathematics Review and Asymptotic Notation
CSE 20 Lecture 12 Induction CK Cheng 1. Induction Outlines Introduction Theorem Examples: The complexity calculation – Tower of Hanoi – Merge Sort – Fibonacci.
Copyright © Cengage Learning. All rights reserved.
Analysis of Algorithms
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Recurrence Relation. Outline  What is a recurrence relation ?  Solving linear recurrence relations  Divide-and-conquer algorithms and recurrence relations.
Module #17: Recurrence Relations Rosen 5 th ed., §
Solving Second-Order Recursive Relations Lecture 36 ½ Section 8.3 Wed, Apr 19, 2006.
RECURRENCE Sequence Recursively defined sequence
Control Engineering Lecture# 10 & th April’2008.
Arithmetic Sequences Standard: M8A3 e. Use tables to describe sequences recursively and with a formula in closed form.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Recurrence.
1 CSE 20 Lecture 11 Function, Recursion & Analysis CK Cheng UC San Diego.
9.1 Notes Geometric Mean. 9.1 Notes Arithmetic mean is another term that means the same thing as average. The second do now question could have been,
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Recursion Algorithm : Design & Analysis [3]. In the last class… Asymptotic growth rate The Sets ,  and  Complexity Class An Example: Maximum Subsequence.
Chapter 8 Recursion. 8.3 More Recurrence Second-Order Recurrence Definition – A second-order linear homogeneous recurrence relation with constant coefficients.
12/19/ Non- homogeneous Differential Equation Chapter 4.
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.
Sequences and Series!! !. Finding the Degree of a Sequence Begin by finding the difference between adjacent numbers.
Asymptotics and Recurrence Equations Prepared by John Reif, Ph.D. Analysis of Algorithms.
CSE 2813 Discrete Structures Solving Recurrence Relations Section 6.2.
Agenda Lecture Content:  Recurrence Relations  Solving Recurrence Relations  Iteration  Linear homogenous recurrence relation of order k with constant.
Infinite Geometric Series Recursion & Special Sequences Definitions & Equations Writing & Solving Geometric Series Practice Problems.
RECURRENCE Sequence Recursively defined sequence
Ch 4.2: Homogeneous Equations with Constant Coefficients Consider the nth order linear homogeneous differential equation with constant, real coefficients:
1 RECURRENCE 1. Sequence 2. Recursively defined sequence 3. Finding an explicit formula for recurrence relation.
Mathematical Analysis of Recursive Algorithm CSG3F3 Lecture 7.
Chapter 2 Fundamentals of the Analysis of Algorithm Efficiency Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar Dr Nazir A. Zafar Advanced Algorithms Analysis and Design.
Digital Signal Processing
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
CMSC Discrete Structures
7.2 GEOMETRIC Sequences.
Recursion and Recurrence Relations
Modeling with Recurrence Relations
Analysis of Algorithms
3.5 Recurrence Relations.
Introduction to Recurrence Relations
Sequences Write down the next 3 terms in each sequence:
CS 3343: Analysis of Algorithms
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Ch 4.2: Homogeneous Equations with Constant Coefficients
Notes Over 11.5 Recursive Rules
Topic 3: Prob. Analysis Randomized Alg.
CMSC Discrete Structures
Solving Recurrence Relations
Time Complexity Lecture 14 Sec 10.4 Thu, Feb 22, 2007.
Applied Discrete Mathematics Week 7: Computation
CMSC Discrete Structures
At the end of this session, learner will be able to:
Recurrence Relations Discrete Structures.
Module 3 Arithmetic and Geometric Sequences
Recurrence Relations.
Recurrence Relations Rosen 5th ed., §6.2 5/22/2019
Module 3 Arithmetic and Geometric Sequences
ICS 253: Discrete Structures I
Presentation transcript:

1 CSE 20 Lecture 13: Analysis of Recursive Functions CK Cheng

2 3. Analysis 3.1 Introduction 3.2 Homogeneous Linear Recursion

3 3.1 Introduction Derive the bound of functions or recursions Estimate CPU time and memory allocation Eg. PageRank calculation Allocation of memory, CPU time, Resource optimization MRI imaging Real time? VLSI design Design automation flow to meet the deadline for tape out? Further Study Algorithm, Complexity

4 3.1 Introduction Derive the bound of functions or recursions Estimate CPU time and memory allocation Example on Fibonacci Sequence: Estimate f n. – Index: – f n :

5 Example: Fibonacci Sequence

6 Example: Fibonacci Sequence, iClicker Suppose g 0 =0 and g 1 =2, g n =g n-1 +g n-2 what is g n A. g n =f n B. g n =2f n C. g n =3f n D. None of the above

7 3.2 Homogeneous Linear Recursion (1) Arithmetic Recursion a, a+d, a+2d, …, a+kd (2) Geometric Recursion a, ar, ar 2, …, ar k (3) Linear Recursion a n = e 1 a n-1 +e 2 a n-2 +…+e k a n-k + f(n)

8 Linear Recursion and Homogeneous Linear Recursion Linear Recursion: There are no powers or products of Homogenous Linear Recursion: A linear recursion with f(n)=0.

9 Solving Linear Recursion Input: Formula and k initial values Output: a n as a function of n 1. Set characteristic polynomial: 2. Find the root of the characteristic polynomial (assuming r i are distinct) 3. Express 4. Determine c i from k initial values

10 Solving Linear Recursion Input: Formula and k initial values 1. Set characteristic polynomial: Rewrite the formula with n=k Replace a i with x i

11 Solving Linear Recursion Input: Formula and k initial values 2. Find the root of the polynomial Or,

12 Solving Linear Recursion Input: Formula and k initial values 3. Express (assuming that the roots are distinct.) 4. Determine c i from k initial values

13 Solving Linear Recursion Input: Formula and k initial values 3. Set (when the roots are not distinct.) where r i is a root of multiplicity w i

Example on Fibonacci sequence Input: initial values a 0 =0 and a 1 =1; and recursion formula a n =a n-1 +a n-2. Rewrite recursion: a n -a n-1 -a n-2 =0. Or a 2 -a 1 -a 0 =0. 1. Characteristic polynomial: x 2 -x-1=0. 2. Roots of the polynomial: Set: a n =c 1 r 1 n +c 2 r 2 n.

Example on Fibonacci sequence Input: initial values a 0 =0 and a 1 =1; and recursion formula a n =a n-1 +a n Determine c i from k initial values a 0 =c 1 r 1 0 +c 2 r 2 0 => c 1 +c 2 =0 a 1 =c 1 r 1 1 +c 2 r 2 1 => c 1 r 1 +c 2 r 2 =1. 15 Thus, we have a n =c 1 r 1 n +c 2 r 2 n, where

16 Example 2

Example 2 (cont) Two initial values a 0 =c 1 +c 2 :c 1 +c 2 =1 a 1 =2c 1 +(-1)c 2 :2c 1 -c 2 =1 Thus, we have c 1 =2/3, c 2 =1/3. Since a n =c 1 r 1 n +c 2 r 2 n, we have a n =2/3×2 n +1/3×(-1) n, 17

18 Example 3