diff --git a/C++/Fibonacci_using_tabulation.cpp b/C++/Fibonacci_using_tabulation.cpp new file mode 100644 index 00000000..87d1ab19 --- /dev/null +++ b/C++/Fibonacci_using_tabulation.cpp @@ -0,0 +1,29 @@ +//Finding Fibonacci number using tabulation (Bottom to top approach) +#include +#include +using namespace std; +int Fibonacci(int n) +{ + vectordp(n+1); + dp[0]=0; + dp[1]=1; + for(int i=2;i> n; + cout << "Fibonacci number at position " << n << " is: " << Fibonacci(n) << endl; +} + +/* +Complexity analysis +T.C=O(N) as there is one loop running from i=2 to n +S.C=O(N) as we are storing the previously computed result +As we are going from bottom to top [From 0 to N] this is bottom to top approach [Tabulation] +*/ \ No newline at end of file