mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-24 04:06:28 +08:00
Add the summary of chapter divide and conquer
Enable instant loading feature Fix the math rendering in mathjax.js
This commit is contained in:
parent
06b309d021
commit
34985bdf2b
4 changed files with 47 additions and 3 deletions
11
docs/chapter_divide_and_conquer/summary.md
Normal file
11
docs/chapter_divide_and_conquer/summary.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# 小结
|
||||
|
||||
- 分治算法是一种常见的算法设计策略,包括分(划分)和治(合并)两个阶段,通常基于递归实现。
|
||||
- 判断是否是分治算法问题的依据包括:问题能否被分解、子问题是否独立、子问题是否可以被合并。
|
||||
- 归并排序是分治策略的典型应用,其递归地将数组划分为等长的两个子数组,直到只剩一个元素时开始逐层合并,从而完成排序。
|
||||
- 引入分治策略往往可以带来算法效率的提升。一方面,分治策略减少了计算吧操作数量;另一方面,分治后有利于系统的并行优化。
|
||||
- 分治既可以解决许多算法问题,也广泛应用于数据结构与算法设计中,处处可见其身影。
|
||||
- 相较于暴力搜索,自适应搜索效率更高。时间复杂度为 $O(\log n)$ 的搜索算法通常都是基于分治策略实现的。
|
||||
- 二分查找也体现了分治思想,我们可以通过递归分治实现二分查找。
|
||||
- 在构建二叉树问题中,构建树(原问题)可以被划分为构建左子树和右子树(子问题),其可以通过划分前序遍历和中序遍历的索引区间来实现。
|
||||
- 在汉诺塔问题中,一个规模为 $n$ 的问题可以被划分为两个规模为 $n-1$ 的子问题和一个规模为 $1$ 的子问题。按顺序解决这三个子问题后,原问题随之得到解决。
|
10
docs/javascripts/katex.js
Normal file
10
docs/javascripts/katex.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
document$.subscribe(({ body }) => {
|
||||
renderMathInElement(body, {
|
||||
delimiters: [
|
||||
{ left: "$$", right: "$$", display: true },
|
||||
{ left: "$", right: "$", display: false },
|
||||
{ left: "\\(", right: "\\)", display: false },
|
||||
{ left: "\\[", right: "\\]", display: true },
|
||||
],
|
||||
});
|
||||
});
|
16
docs/javascripts/mathjax.js
Normal file
16
docs/javascripts/mathjax.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
window.MathJax = {
|
||||
tex: {
|
||||
inlineMath: [["\\(", "\\)"]],
|
||||
displayMath: [["\\[", "\\]"]],
|
||||
processEscapes: true,
|
||||
processEnvironments: true,
|
||||
},
|
||||
options: {
|
||||
ignoreHtmlClass: ".*|",
|
||||
processHtmlClass: "arithmatex",
|
||||
},
|
||||
};
|
||||
|
||||
document$.subscribe(() => {
|
||||
MathJax.typesetPromise();
|
||||
});
|
13
mkdocs.yml
13
mkdocs.yml
|
@ -28,7 +28,7 @@ theme:
|
|||
# - header.autohide
|
||||
# - navigation.expand
|
||||
- navigation.indexes
|
||||
# - navigation.instant
|
||||
- navigation.instant
|
||||
# - navigation.prune
|
||||
# - navigation.sections
|
||||
# - navigation.tabs
|
||||
|
@ -121,8 +121,13 @@ extra_javascript:
|
|||
- javascripts/mathjax.js
|
||||
- https://polyfill.io/v3/polyfill.min.js?features=es6
|
||||
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
|
||||
# - javascripts/katex.js
|
||||
# - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/katex.min.js
|
||||
# - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/contrib/auto-render.min.js
|
||||
|
||||
extra_css:
|
||||
- stylesheets/extra.css
|
||||
# - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/katex.min.css
|
||||
|
||||
# Page tree
|
||||
nav:
|
||||
|
@ -220,7 +225,7 @@ nav:
|
|||
- 11.10. 基数排序: chapter_sorting/radix_sort.md
|
||||
- 11.11. 小结: chapter_sorting/summary.md
|
||||
- 12. 分治:
|
||||
# [icon: material/file-tree-outline]
|
||||
# [icon: material/file-tree-outline, status: new]
|
||||
- chapter_divide_and_conquer/index.md
|
||||
# [status: new]
|
||||
- 12.1. 分治算法: chapter_divide_and_conquer/divide_and_conquer.md
|
||||
|
@ -230,6 +235,8 @@ nav:
|
|||
- 12.3. 构建树问题: chapter_divide_and_conquer/build_binary_tree_problem.md
|
||||
# [status: new]
|
||||
- 12.4. 汉诺塔问题: chapter_divide_and_conquer/hanota_problem.md
|
||||
# [status: new]
|
||||
- 12.5. 小结: chapter_divide_and_conquer/summary.md
|
||||
- 13. 回溯:
|
||||
# [icon: material/map-marker-path]
|
||||
- chapter_backtracking/index.md
|
||||
|
@ -239,7 +246,7 @@ nav:
|
|||
- 13.4. N 皇后问题: chapter_backtracking/n_queens_problem.md
|
||||
- 13.5. 小结: chapter_backtracking/summary.md
|
||||
- 14. 动态规划:
|
||||
# [icon: material/table-pivot]
|
||||
# [icon: material/table-pivot, status: new]
|
||||
- chapter_dynamic_programming/index.md
|
||||
# [status: new]
|
||||
- 14.1. 初探动态规划: chapter_dynamic_programming/intro_to_dynamic_programming.md
|
||||
|
|
Loading…
Reference in a new issue