mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-08 12:06:27 +08:00
build
This commit is contained in:
@@ -41,7 +41,7 @@ comments: true
|
||||
|
||||
图 14-10 展示了一个例子,给定网格的最小路径和为 $13$ 。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 14-10 最小路径和示例数据 </p>
|
||||
|
||||
@@ -53,7 +53,7 @@ comments: true
|
||||
|
||||
至此,我们就得到了图 14-11 所示的二维 $dp$ 矩阵,其尺寸与输入网格 $grid$ 相同。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 14-11 状态定义与 dp 表 </p>
|
||||
|
||||
@@ -73,7 +73,7 @@ $$
|
||||
dp[i, j] = \min(dp[i-1, j], dp[i, j-1]) + grid[i, j]
|
||||
$$
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 14-12 最优子结构与状态转移方程 </p>
|
||||
|
||||
@@ -89,7 +89,7 @@ $$
|
||||
|
||||
如图 14-13 所示,由于每个格子是由其左方格子和上方格子转移而来,因此我们使用采用循环来遍历矩阵,外循环遍历各行、内循环遍历各列。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 14-13 边界条件与状态转移顺序 </p>
|
||||
|
||||
@@ -368,7 +368,7 @@ $$
|
||||
|
||||
本质上看,造成重叠子问题的原因为:**存在多条路径可以从左上角到达某一单元格**。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 14-14 暴力搜索递归树 </p>
|
||||
|
||||
@@ -697,7 +697,7 @@ $$
|
||||
|
||||
如图 14-15 所示,在引入记忆化后,所有子问题的解只需计算一次,因此时间复杂度取决于状态总数,即网格尺寸 $O(nm)$ 。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 14-15 记忆化搜索递归树 </p>
|
||||
|
||||
@@ -1039,40 +1039,40 @@ $$
|
||||
数组 `dp` 大小为 $n \times m$ ,**因此空间复杂度为 $O(nm)$** 。
|
||||
|
||||
=== "<1>"
|
||||

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

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

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

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

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

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

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

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

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

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

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

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 14-16 最小路径和的动态规划过程 </p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user