Algorithm for Recursive Memoization
Updated: 01 February 2024
The Recipe
The recipe for working with this kind of memoization, and memoization more generally is:
- Start with some brute force recursion - ensure to have a base case
- Define a memo and a value that wil be used a key to identify a subtree. This is the parameter that changes
- Check the memo as another base case, if exists then return
- Get the new result ensuring to pass through the memo
- Memoize the new result
- Return the new result