mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Update README.md
This commit is contained in:
parent
2861501448
commit
aca9429097
@ -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}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user