From aca94290972b80e539fa18b9c73158899a60b66b Mon Sep 17 00:00:00 2001 From: marina <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Mon, 7 Aug 2023 16:51:23 -0700 Subject: [PATCH] Update README.md --- dynamic_programming/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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}