mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-25 19:22:27 +08:00
build
This commit is contained in:
@ -14,7 +14,7 @@ comments: true
|
||||
2. 每次只能移动一个圆盘。
|
||||
3. 小圆盘必须时刻位于大圆盘之上。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 12-10 汉诺塔问题示例 </p>
|
||||
|
||||
@ -25,10 +25,10 @@ comments: true
|
||||
如图 12-11 所示,对于问题 $f(1)$ ,即当只有一个圆盘时,我们将它直接从 `A` 移动至 `C` 即可。
|
||||
|
||||
=== "<1>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<2>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 12-11 规模为 1 问题的解 </p>
|
||||
|
||||
@ -39,16 +39,16 @@ comments: true
|
||||
3. 最后将小圆盘从 `B` 移至 `C` 。
|
||||
|
||||
=== "<1>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<2>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<3>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<4>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 12-12 规模为 2 问题的解 </p>
|
||||
|
||||
@ -65,16 +65,16 @@ comments: true
|
||||
3. 令 `C` 为目标柱、`A` 为缓冲柱,将两个圆盘从 `B` 移动至 `C` 。
|
||||
|
||||
=== "<1>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<2>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<3>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "<4>"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 12-13 规模为 3 问题的解 </p>
|
||||
|
||||
@ -88,7 +88,7 @@ comments: true
|
||||
|
||||
对于这两个子问题 $f(n-1)$ ,**可以通过相同的方式进行递归划分**,直至达到最小子问题 $f(1)$ 。而 $f(1)$ 的解是已知的,只需一次移动操作即可。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 12-14 汉诺塔问题的分治策略 </p>
|
||||
|
||||
@ -485,7 +485,7 @@ comments: true
|
||||
|
||||
如图 12-15 所示,汉诺塔问题形成一个高度为 $n$ 的递归树,每个节点代表一个子问题、对应一个开启的 `dfs()` 函数,**因此时间复杂度为 $O(2^n)$ ,空间复杂度为 $O(n)$** 。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 12-15 汉诺塔问题的递归树 </p>
|
||||
|
||||
|
Reference in New Issue
Block a user