next up previous
Next: Solution Techniques Up: l2 Previous: Example - Wrong Way

Example - Right Way

T(n) = $\Theta(n)$ + T(n/3)
= $\Theta(n)$ + [$\Theta(n/3)$ + T(n/$3^2$)]
= $\Theta(n)$ + $\Theta(n/3)$ + T(n/$3^2$)
= $\Theta(n)$ + $\Theta(n/3)$ + $\Theta(n/3^2)$ + T(n/$3^3$)
= \(\sum_{i=0}^{log_3 n-1} \; \Theta(n/3^i)\) + T(1)
= \(\Theta(n \sum_{i=0}^{log_3 n-1} \; (1/3)^i)\) + T(1)
= \(\Theta(n (\frac{(1/3)^{log_3 n} - 1}{1/3 - 1}))\) + T(1)
= \(\Theta(3/2n(1 - 1/n))\) + T(1)
= \(\Theta(\frac{3n}{2} - \frac{3n}{n})\) + T(1)
= \(\Theta(n)\)


next up previous
Next: Solution Techniques Up: l2 Previous: Example - Wrong Way