Example #6: Learning from Analysis
To avoid recursive calls
- store all basis values in a table
- each time you calculate an answer, store it in the table
- before performing any calculation for a value n
- check if a valid answer for n is in the table
- if so, return it
This strategy is called “memoization” and is closely related to dynamic programming
How much time does this version take?