Update README.md

This commit is contained in:
marina 2023-08-07 16:51:23 -07:00 committed by GitHub
parent 2861501448
commit aca9429097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,11 +50,12 @@ def reverse(s):
<br> <br>
* memoization is an optimization technique that avoids recursion's duplicate calculations. * memoization is an optimization technique that avoids recursion's duplicate calculations.
* it's primarily used to speed up code by storing the intermediate results in a cache so that it can be reused later. * it's primarily used to speed up code by storing the intermediate results in a cache so that it can be reused later.
* for example, a hash table can be used as a cache and should be passed along each subroutine call. * for example, a hash table can be used as a cache and should be passed along each subroutine call.
* here is a basic template with pseudo-code: * here is a basic template with pseudo-code:
<br>
```python ```python
function dp(dp_state, memo_dict): function dp(dp_state, memo_dict):
@ -75,6 +76,8 @@ function answerToProblem(input)
* classic examples where memoization can be used are fibonacci and the "climbing stairs" problem: * classic examples where memoization can be used are fibonacci and the "climbing stairs" problem:
<br>
```python ```python
cache = {1: 1, 0: 1} cache = {1: 1, 0: 1}