next up previous
Next: Up: Previous:

Solution Techniques

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



Guess: O(n)



Show: T(n) <= cn



Assume: T(n-1) <= c(n-1)



T(n) $\leq$ c(n-1) + $\Theta(1)$
= cn - c + $\Theta(1)$
$\leq$ cn
If c $\geq \Theta(1)$. True for large enough c.



Initial Conditions: T(1) = $\Theta(1)$$\leq$ cn


next up previous
Next: Up: Previous: