02 Recursive Algorithm Complexity Part 1
02 Recursive Algorithm Complexity Part 1
T(n) ≈ copC(n)
Where :
T(n) : running time
n : input size
cop : execution time for basic operation
C(n) : number of times basic operation is executed
Counting the number of times the algorithm’s basic operation is executed on input of
size n.
7tn – 3tn-1 = 0
6tn – 5tn-1 + 8tn-2 = 0
8tn – 4tn-3 = 0
The characteristic equation for the homogeneous linear recurrence equation with
constant coefficients
a0tn + a1tn-1 + … + aktn-k = 0
is defined as
a0rk + a1rk-1 + … + akr0 = 0
5r2 + 7r + 6 = 0
We use an arrow to show that the order of the characteristic equation is k
(in this case is 2)’
Theorem
Let the homogeneous linear recurrence equation with constant coefficients
a0tn + a1tn-1 + … + aktn-k = 0
be given. If its characteristic equation
a0rk + a1rk-1 + … + akr0 = 0
has k distinct solutions r1, r2, . . . , rk, then the only solutions to the recurrence are
n n n
tn = c1r1 + c2r2 + … + ckrk
5. substitute the constant into the general solution to obtain the particular
solution
tn = c14n + c2(-1)n
1 1
tn = 5 4n - 5 (-1)n
Theorem
Let r be a root of multiplicity m of the characteristic equation for a homogeneous
linear recurrence with constant coefficients. Then
tn = rn, tn = nrn. tn = n2rn, tn = n3rn, …, tn = nm-1rn
are all solution to the recurrence.
To be continued in part 2
References