Top-Down implementation of Dynamic Programming
Memoization
Memoization stores the values of the function in an array after calculating them, so those values don’t need to be computed again.
Steps from FreeCodeCamp
- Make it work (with recursion)
- Visualize the problem as a tree
- Implement the tree using recursion
- Test it
- Make it efficient (memoize)
- add a memo object to the recursive function argument
- add a base case to return memo values
- store return values into the memo
Example
Memoization with fibonacci problem.