File tree 1 file changed +3
-3
lines changed
Contents/09.Algorithm-Base/02.Recursive-Algorithm
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -54,9 +54,9 @@ fact(6)
54
54
55
55
这两个部分也可以叫做「递推过程」和「回归过程」,如下面两幅图所示:
56
56
57
- ![ ] ( https://qcdn.itcharge.cn/images/20220407160648.png )
57
+ ![ 递推过程 ] ( https://qcdn.itcharge.cn/images/20220407160648.png )
58
58
59
- ![ ] ( https://qcdn.itcharge.cn/images/20220407160659.png )
59
+ ![ 回归过程 ] ( https://qcdn.itcharge.cn/images/20220407160659.png )
60
60
61
61
如上面所说,我们可以把「递归」分为两个部分:「递推过程」和「回归过程」。
62
62
@@ -175,7 +175,7 @@ $f(n) = \begin{cases} 0 & n = 0 \cr 1 & n = 1 \cr f(n - 2) + f(n - 1) & n > 1 \e
175
175
176
176
其对应的递归过程如下图所示:
177
177
178
- ![ ] ( https://qcdn.itcharge.cn/images/20230307164107.png )
178
+ ![ 斐波那契数列的递归过程 ] ( https://qcdn.itcharge.cn/images/20230307164107.png )
179
179
180
180
从图中可以看出:想要计算 $f(5)$,需要先计算 $f(3)$ 和 $f(4)$,而在计算 $f(4)$ 时还需要计算 $f(3)$,这样 $f(3)$ 就进行了多次计算。同理 $f(0)$、$f(1)$、$f(2)$ 都进行了多次计算,就导致了重复计算问题。
181
181
You can’t perform that action at this time.
0 commit comments