next up previous
Next: Solution Techniques Up: l2 Previous: Solution Techniques

Example: Fibonacci



Fibonacci(n)
$\;\;\;\;\;$if n $<$ 2
$\;\;\;\;\;$then return n
$\;\;\;\;\;$else return Fibonacci(n-1) + Fibonacci(n-2)



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


next up previous
Next: Solution Techniques Up: l2 Previous: Solution Techniques