Skip to content

Commit 512ea89

Browse files
committedMay 14, 2024
Update 01.Memoization.md
1 parent 87d96c7 commit 512ea89

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎Contents/10.Dynamic-Programming/02.Memoization/01.Memoization.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
举个例子,比如「斐波那契数列」的定义是:$f(0) = 0, f(1) = 1, f(n) = f(n - 1) + f(n - 2)$。如果我们使用递归算法求解第 $n$ 个斐波那契数,则对应的递推过程如下:
88

9-
![](https://qcdn.itcharge.cn/images/20230308105357.png)
9+
![记忆化搜索](https://qcdn.itcharge.cn/images/20240514110503.png)
1010

1111
从图中可以看出:如果使用普通递归算法,想要计算 $f(5)$,需要先计算 $f(3)$ 和 $f(4)$,而在计算 $f(4)$ 时还需要计算 $f(3)$。这样 $f(3)$ 就进行了多次计算,同理 $f(0)$、$f(1)$、$f(2)$ 都进行了多次计算,从而导致了重复计算问题。
1212

0 commit comments

Comments
 (0)
Please sign in to comment.