next up previous
Next: Example - Right Way Up: CSE 2320: Algorithms and 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/32)]
=
$\Theta(n)$ + $\Theta(n)$ + T(n/32)
Terminates when
n/3i = 1, or i = log3 n.
=
\(\sum_{i=0}^{log_3 n-1} \Theta(n)\) + T(1)
=
\(\Theta(n log_3 n)\), not what we want!!!



Copyright © 1998 The University of Texas at Arlington