Download presentation
Presentation is loading. Please wait.
1
1 CSE 20 Lecture 12: Analysis of Homogeneous Linear Recursion CK Cheng May 5, 2011
2
2 3. Analysis 3.1 Introduction 3.2 Homogeneous Linear Recursion 3.3 Pigeonhole Principle 3.4 Inclusion-Exclusion Principle
3
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
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: 0 1 2 3 4 5 6 7 8 9 – f n : 0 1 1 2 3 4 5 8 13 21 34
5
5 Example: Fibonacci Sequence 0123456789 0112358132134
6
6 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)
7
7 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.
8
8 Solving Linear Recursion Input: Formula and k initial values (1) characteristic polynomial: (2)Find the root of the characteristic polynomial (assuming r i are distinct) (3)Set (4)Determine c i from k initial values
9
9 Solving Linear Recursion Input: Formula and k initial values (1) characteristic polynomial: Rewrite the formula with n=k Replace a i with x i
10
10 Solving Linear Recursion Input: Formula and k initial values 2. Find the root of the polynomial Or,
11
11 Solving Linear Recursion Input: Formula and k initial values 3. Set (assuming that the roots are distinct.) 4. Determine c i from k initial values
12
12 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
13
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. 1. Characteristic polynomial: x 2 -x-1=0. 2. Roots of the polynomial: 13 3. Set: a n =c 1 r 1 n +c 2 r 2 n.
14
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. 4. Determine ci 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, where 14 Thus, we have
15
Example 2 Given initial values a 0 =1 and a 1 =1; and recursion formula: a n =a n-1 +2a n-2 Rewrite recursion: a n -a n-1 -2a n-2 =0 1. Characteristic polynomial: x 2 -x-2=0 2. Characteristic roots: r 1 =2 and r 2 = -1 3. We have a n =c 1 r 1 n +c 2 r 2 n =c 1 2 n +c 2 (-1) n 4. We use two initial values for n=0 and n=1: a 0 =c 1 +c 2 a 1 =c 1 2+c 2 (-1) 15
16
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, the formula is a n =2/3*2 n +1/3*(-1) n, 16
17
Example 3 (identical roots) Given initial values a 0 =1 and a 1 =1; and recursion a n =-2a n-1 -a n-2 Rewrite the recursion: a n +2a n-1 +a n-2 =0 1.Characteristic polynomial: x 2 +2x+1=0 2.Characteristic roots: r 1 =r 2 =-1 3.Formula for roots of multiplicity 2 a n =c 1 r 1 n +c 2 nr 1 n =c 1 (-1) n +c 2 n(-1) n Note the formula is different for roots of multiplicity. 17
18
Example 3 (identical roots) Given initial values a 0 =1 and a 1 =1; and recursion a n =-2a n-1 -a n-2 4. Two initial conditions: a 0 =c 1 (-1) 0 +c 2 0(-1) 0 =c 1 a 1 =c 1 (-1) 1 +c 2 1(-1) 1 =-c 1 -c 2 with a 0 =1 and a 1 =1 Thus, c 1 = 1 and c 2 = -2. Therefore, a n = (-1) n -2n(-1) n Exercise: verify the sequence a 2, a 3 and a 4. 18
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.