Recurrence Relation-Recursion Tree
Recurrence Relation-Recursion Tree
Recursion Tree
Step-01:
Draw a recursion tree based on the given recurrence relation.
Step-02:
Determine-
•Cost of each level
•Total number of levels in the recursion tree
•Number of nodes in the last level
•Cost of the last level
Step-03:
Add cost of all the levels of the recursion tree and simplify the expression so obtained in terms of
Solve the following recurrence relation using recursion tree method-
T(n) = 2T(n/2) + n
Step-01:
Add costs of all the levels of the recursion tree and simplify the
expression so obtained in terms of asymptotic notation-
n x log2n + θ (n)
= nlog2n + θ (n)
= θ (nlog2n)
Problem-02: Solve the following recurrence relation using recursion tree method-
T(n) = T(n/5) + T(4n/5) + n
• nlog5/4n + θ(nlog5/42)
• = θ(nlog5/4n)
Problem-03:
Step-06:
Add costs of all the levels of the recursion tree and simplify the
expression so obtained in terms of asymptotic notation-
Recursion Tree
Recursion Tree
On solving, we get-
= (16/13)cn2 { 1 – (3/16)log4n } + θ(nlog43)
= (16/13)cn2 – (16/13)cn2 (3/16)log4n + θ(nlog43)
= O(n2)
Questions
1. T(n)=T(n/3)+T(2n/3)+n
2. T(n) = 2T(n/2) + n2