The document discusses different methods for analyzing recursive functions, including:
1. The recursion-tree method, which represents each subproblem as a node with costs summed at each level and total. This is suitable for divide-and-conquer recurrences.
2. An example of using the recursion-tree method to solve T(n)=3T(n/4)+Θ(n^2), showing the tree has height log4n, Θ(nlog43) leaf nodes each costing T(1), and total cost O(n^2).
3. Another example of T(n)=T(n/3)+T(2n/3)+O(n
1 of 8
More Related Content
Recurrence theorem
1. 1
Asymptotic Efficiency of Recurrences
• Find the asymptotic bounds of recursive
equations.
– Substitution method
• domain transformation
• Changing variable
– Recursive tree method
– Master method (master theorem)
• Provides bounds for: T(n) = aT(n/b)+f(n) where
– a ≥ 1 (the number of subproblems).
– b>1, (n/b is the size of each subproblem).
– f(n) is a given function.
2. 2
Recurrences
• MERGE-SORT
– Contains details:
• T(n) = Θ(1) if n=1
T(n/2)+ T(n/2)+ Θ(n) if n>1
• Ignore details, T(n) = 2T(n/2)+ Θ(n).
– T(n) = Θ(1) if n=1
2T(n/2)+ Θ(n) if n>1
3. 3
The Recursion-tree Method
• Idea:
– Each node represents the cost of a single subproblem.
– Sum up the costs with each level to get level cost.
– Sum up all the level costs to get total cost.
• Particularly suitable for divide-and-conquer
recurrence.
• Best used to generate a good guess, tolerating
“sloppiness”.
• If trying carefully to draw the recursion-tree and
compute cost, then used as direct proof.
6. 6
Prove the above Guess
• T(n)=3T(n/4)+Θ(n2
) =O(n2
).
• Show T(n) ≤dn2
for some d.
• T(n) ≤3(d (n/4)2
) +cn2
≤3(d (n/4)2
) +cn2
=3/16(dn2
) +cn2
≤ dn2
, as long as d≥(16/13)c.
7. 7
One more example
• T(n)=T(n/3)+ T(2n/3)+O(n).
• Construct its recursive tree (
Figure 4.2, page 71).
• T(n)=O(cnlg3/2
n) = O(nlg n).
• Prove T(n) ≤ dnlg n.