1. Fibonacci - 1 #

Created Sunday 08 March 2020

Let us first discuss a problem: finding the nth fibonacci number. It can be written like a recursion; i.e here we do two recursions blindly, this is very costly in terms of time. Solving using recursive tree. T(n) = 2T(n-1) + k, on solving using GP formula T(n) = 2^n-1^.k = O(2^n^)

Things to keep in mind in DP:

Analysis after using DP: Nor right calls made. Complexity = nodes = O(n). Space is also optimized a lot here. Code using DP:

Discussion: This ‘storing’ is called memoization. It is a **top-down **approach, where we save the previous answers and use them in the future.