Fix some figures.
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
|
@ -182,8 +182,9 @@
|
||||||
=== "<9>"
|
=== "<9>"
|
||||||
![built_tree_step9](build_binary_tree_problem.assets/built_tree_step9.png)
|
![built_tree_step9](build_binary_tree_problem.assets/built_tree_step9.png)
|
||||||
|
|
||||||
=== "<10>"
|
每个递归函数内的前序遍历 `preorder` 和中序遍历 `inorder` 的划分结果如下图所示。
|
||||||
![built_tree_step10](build_binary_tree_problem.assets/built_tree_step10.png)
|
|
||||||
|
![每个递归函数中的划分结果](build_binary_tree_problem.assets/built_tree_overall.png)
|
||||||
|
|
||||||
设树的节点数量为 $n$ ,初始化每一个节点(执行一个递归函数 `dfs()` )使用 $O(1)$ 时间。**因此总体时间复杂度为 $O(n)$** 。
|
设树的节点数量为 $n$ ,初始化每一个节点(执行一个递归函数 `dfs()` )使用 $O(1)$ 时间。**因此总体时间复杂度为 $O(n)$** 。
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 38 KiB |
|
@ -44,7 +44,7 @@ $$
|
||||||
|
|
||||||
**贪心策略二**:在切分方案中,最多只应存在两个 $2$ 。因为三个 $2$ 总是可以被替换为两个 $3$ ,从而获得更大乘积。
|
**贪心策略二**:在切分方案中,最多只应存在两个 $2$ 。因为三个 $2$ 总是可以被替换为两个 $3$ ,从而获得更大乘积。
|
||||||
|
|
||||||
![最优切分因子](max_product_cutting_problem.assets/max_product_cutting_greedy_infer3.png)
|
![最优切分因子](max_product_cutting_problem.assets/max_product_cutting_greedy_infer2.png)
|
||||||
|
|
||||||
总结以上,可推出以下贪心策略。
|
总结以上,可推出以下贪心策略。
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
|
@ -11,19 +11,19 @@
|
||||||
3. 不断重复步骤 `1.` 和 步骤 `2.` ,直至找到拼音首字母为 $r$ 的页码为止。
|
3. 不断重复步骤 `1.` 和 步骤 `2.` ,直至找到拼音首字母为 $r$ 的页码为止。
|
||||||
|
|
||||||
=== "<1>"
|
=== "<1>"
|
||||||
![查字典步骤](algorithms_are_everywhere.assets/binary_search_dictionary_step_1.png)
|
![查字典步骤](algorithms_are_everywhere.assets/binary_search_dictionary_step1.png)
|
||||||
|
|
||||||
=== "<2>"
|
=== "<2>"
|
||||||
![binary_search_dictionary_step_2](algorithms_are_everywhere.assets/binary_search_dictionary_step_2.png)
|
![binary_search_dictionary_step2](algorithms_are_everywhere.assets/binary_search_dictionary_step2.png)
|
||||||
|
|
||||||
=== "<3>"
|
=== "<3>"
|
||||||
![binary_search_dictionary_step_3](algorithms_are_everywhere.assets/binary_search_dictionary_step_3.png)
|
![binary_search_dictionary_step3](algorithms_are_everywhere.assets/binary_search_dictionary_step3.png)
|
||||||
|
|
||||||
=== "<4>"
|
=== "<4>"
|
||||||
![binary_search_dictionary_step_4](algorithms_are_everywhere.assets/binary_search_dictionary_step_4.png)
|
![binary_search_dictionary_step4](algorithms_are_everywhere.assets/binary_search_dictionary_step4.png)
|
||||||
|
|
||||||
=== "<5>"
|
=== "<5>"
|
||||||
![binary_search_dictionary_step_5](algorithms_are_everywhere.assets/binary_search_dictionary_step_5.png)
|
![binary_search_dictionary_step5](algorithms_are_everywhere.assets/binary_search_dictionary_step5.png)
|
||||||
|
|
||||||
查阅字典这个小学生必备技能,实际上就是著名的二分查找算法。从数据结构的角度,我们可以把字典视为一个已排序的“数组”;从算法的角度,我们可以将上述查字典的一系列操作看作是“二分查找”。
|
查阅字典这个小学生必备技能,实际上就是著名的二分查找算法。从数据结构的角度,我们可以把字典视为一个已排序的“数组”;从算法的角度,我们可以将上述查字典的一系列操作看作是“二分查找”。
|
||||||
|
|
||||||
|
|