next up previous
Next: Example - Right Way Up: l2 Previous: Example - Right Way

Example - Wrong Way

\( T(n) = \left\{ \begin{array}{ll}
\Theta(1) & {\rm if} \; n = 1 \\
T(n/3) + \Theta(n) & {\rm if} \; n > 1
\end{array} \right.\)

T(n) = $\Theta(n)$ + T(n/3)
= $\Theta(n)$ + [$\Theta(n/3)$ + T(n/$3^2$)]
= $\Theta(n)$ + $\Theta(n)$ + T(n/$3^2$)
Terminates when $n/3^i = 1$, or $i = log_3 n$.
= \(\sum_{i=0}^{log_3 n-1} \Theta(n)\) + T(1)
= \(\Theta(n log_3 n)\), not what we want!!!


next up previous
Next: Example - Right Way Up: l2 Previous: Example - Right Way