diff --git a/dynamic_programming/README.md b/dynamic_programming/README.md index 3446e2b..b6bce42 100644 --- a/dynamic_programming/README.md +++ b/dynamic_programming/README.md @@ -50,11 +50,12 @@ def reverse(s):
* 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: +
+ ```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: +
+ ```python cache = {1: 1, 0: 1}