next up previous
Next: Up: Previous:

Example: Factorial

Factorial(n)
$\;\;\;\;\;$if n < 1
$\;\;\;\;\;$then return 1
$\;\;\;\;\;$else return n * Factorial(n-1)



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


next up previous
Next: Up: Previous: