0% found this document useful (0 votes)
21 views

Recurrences: N 1 Then T (1) 1

The document discusses four methods for solving recurrence relations: substitution, iteration, recursion trees, and the master theorem. It then focuses on explaining the iteration method through an example. The iteration method expands the recurrence relation into a summation of terms involving 'n' and the initial condition. It works through the example recurrence relation T(n) = 4T(n/4) + 4 step-by-step to reach the solution T(n) = 1/3(4n-1) through expanding it into a geometric series. The overall runtime is O(n).

Uploaded by

Mahnoor Aslam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Recurrences: N 1 Then T (1) 1

The document discusses four methods for solving recurrence relations: substitution, iteration, recursion trees, and the master theorem. It then focuses on explaining the iteration method through an example. The iteration method expands the recurrence relation into a summation of terms involving 'n' and the initial condition. It works through the example recurrence relation T(n) = 4T(n/4) + 4 step-by-step to reach the solution T(n) = 1/3(4n-1) through expanding it into a geometric series. The overall runtime is O(n).

Uploaded by

Mahnoor Aslam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Recurrences

Four methods to solve a recurrence relation:


1. Substitution method
2. Iteration method
3. Recursion tree method
4. Master theorem method
Iteration Method
It means to expand the recurrence and express it as a summation of
terms ‘n’ and initial condition.
Example:
Solve the following recurrence relation in terms of ‘n’ by using the
iteration method:
T(n) = 4T(n/4) +4 k
1−r i
T(1) = 1 ∑ ar i=a ( 1−r
)
i=1

n=1 Geometric Series

then T(1) = 1

K T(n)
1 T(n) = 4T(n/4) + 4
n/4
T(n) = 4 T( 4 ) +4
T(n/4) = 4T(n/42) + 4
2 T(n) = 4(4T(n/42)+4)+4
T(n) = 42 T(n/42) + 42 + 4
2 n/4 2
T(n/4 ) = 4 T( 4 ) +4
= 4 T(n/43) + 4
3 T(n) = 42 (4T(n/43)+4)+42 +4
T(n) = 43 T(n/43) + 43 + 42 + 4
.
.
.
K T(n) = 4k T(n/4k) + 4k + 4k-1 + … + 4
k
k k
=4 T(n/4 ) + ∑ 4i
i=1

k k 1−4 k
= 4 T(n/4 ) + 1−4
1−4 k
= 4k T(n/4k) + −3
4 k −1
= 4k T(n/4k) + 3
n/4k = 1
n = 4k
taking log on both sides
log4n = k (4log4n = n)

4 log 4n−1

T(n) = 4log4n T(n/4log4n) + 3


= n.T(n/n) + n-1/3
= nT(1) + n-1/3
= n 1 + n-1/3
= n+ n-1/3
=1/3(4n-1)
Runtime = O(n)

You might also like