mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-22 16:31:15 -04:00
Update README.md
This commit is contained in:
parent
2861501448
commit
aca9429097
1 changed files with 4 additions and 1 deletions
|
@ -50,11 +50,12 @@ def reverse(s):
|
|||
<br>
|
||||
|
||||
* 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.
|
||||
* 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:
|
||||
|
||||
<br>
|
||||
|
||||
```python
|
||||
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:
|
||||
|
||||
<br>
|
||||
|
||||
```python
|
||||
cache = {1: 1, 0: 1}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue