Algorithm for Recursive Memoization

Updated: 01 February 2024

The Recipe

The recipe for working with this kind of memoization, and memoization more generally is:

  1. Start with some brute force recursion - ensure to have a base case
  2. Define a memo and a value that wil be used a key to identify a subtree. This is the parameter that changes
  3. Check the memo as another base case, if exists then return
  4. Get the new result ensuring to pass through the memo
  5. Memoize the new result
  6. Return the new result