adding the fibo sequence

This commit is contained in:
Jidong Xiao
2023-09-22 12:24:13 -04:00
parent 764a3e6c21
commit af0a6030a5

View File

@@ -263,16 +263,12 @@ of the vector in reverse order?
## 7.17 Fibonacci Optimization: Order Notation of Time vs. Space
The Fibonacci sequence is defined:
$$
F(n) = \begin{cases}
0 & \text{if } n = 0 \\
1 & \text{if } n = 1 \\
F(n-1) + F(n-2) & \text{otherwise}
\end{cases}
$$
![alt text](fibonacci_sequence.png "fibonacci sequence")
1. Write a simple recursive version of Fibonacci that is a direct translation of the mathematical definition of the
Fibonacci sequence.
2. Write an iterative version of Fibonacci that uses a vector to improve the running time of the function.
3. What is the order notation of the running time for each version?
- Play this [animation](https://jidongxiao.github.io/CSCI1200-DataStructures/animations/dynamic_memory/example1/index.html), which illustrates the time complexity of the recursvie version.
4. What is the order notation of the memory usage for each version?