diff --git a/chapter_appendix/contribution.md b/chapter_appendix/contribution.md index ebe5b8765..26452ad8f 100644 --- a/chapter_appendix/contribution.md +++ b/chapter_appendix/contribution.md @@ -14,7 +14,7 @@ comments: true 然而在本开源书中,内容更迭的时间被缩短至数日甚至几个小时。 -## 16.2.1 内容微调 +### 1. 内容微调 如图 16-1 所示,每个页面的右上角都有“编辑图标”。您可以按照以下步骤修改文本或代码。 @@ -28,7 +28,7 @@ comments: true 图片无法直接修改,需要通过新建 [Issue](https://github.com/krahets/hello-algo/issues) 或评论留言来描述问题,我们会尽快重新绘制并替换图片。 -## 16.2.2 内容创作 +### 2. 内容创作 如果您有兴趣参与此开源项目,包括将代码翻译成其他编程语言、扩展文章内容等,那么需要实施以下 Pull Request 工作流程。 @@ -38,7 +38,7 @@ comments: true 4. 将本地所做更改 Commit ,然后 Push 至远程仓库。 5. 刷新仓库网页,点击“Create pull request”按钮即可发起拉取请求。 -## 16.2.3 Docker 部署 +### 3. Docker 部署 执行以下 Docker 脚本,稍等片刻,即可在网页 `http://localhost:8000` 访问本项目。 diff --git a/chapter_appendix/installation.md b/chapter_appendix/installation.md index 195ee32d2..949441595 100644 --- a/chapter_appendix/installation.md +++ b/chapter_appendix/installation.md @@ -4,56 +4,56 @@ comments: true # 16.1 编程环境安装 -## 16.1.1 VSCode +### 1. VSCode 本书推荐使用开源轻量的 VSCode 作为本地 IDE ,下载并安装 [VSCode](https://code.visualstudio.com/) 。 -## 16.1.2 Java 环境 +### 2. Java 环境 1. 下载并安装 [OpenJDK](https://jdk.java.net/18/)(版本需满足 > JDK 9)。 2. 在 VSCode 的插件市场中搜索 `java` ,安装 Extension Pack for Java 。 -## 16.1.3 C/C++ 环境 +### 3. C/C++ 环境 1. Windows 系统需要安装 [MinGW](https://sourceforge.net/projects/mingw-w64/files/)([配置教程](https://blog.csdn.net/qq_33698226/article/details/129031241)),MacOS 自带 Clang 无须安装。 2. 在 VSCode 的插件市场中搜索 `c++` ,安装 C/C++ Extension Pack 。 3. (可选)打开 Settings 页面,搜索 `Clang_format_fallback Style` 代码格式化选项,设置为 `{ BasedOnStyle: Microsoft, BreakBeforeBraces: Attach }` 。 -## 16.1.4 Python 环境 +### 4. Python 环境 1. 下载并安装 [Miniconda3](https://docs.conda.io/en/latest/miniconda.html) 。 2. 在 VSCode 的插件市场中搜索 `python` ,安装 Python Extension Pack 。 3. (可选)在命令行输入 `pip install black` ,安装代码格式化工具。 -## 16.1.5 Go 环境 +### 5. Go 环境 1. 下载并安装 [go](https://go.dev/dl/) 。 2. 在 VSCode 的插件市场中搜索 `go` ,安装 Go 。 3. 快捷键 `Ctrl + Shift + P` 呼出命令栏,输入 go ,选择 `Go: Install/Update Tools` ,全部勾选并安装即可。 -## 16.1.6 JavaScript 环境 +### 6. JavaScript 环境 1. 下载并安装 [node.js](https://nodejs.org/en/) 。 2. 在 VSCode 的插件市场中搜索 `javascript` ,安装 JavaScript (ES6) code snippets 。 3. (可选)在 VSCode 的插件市场中搜索 `Prettier` ,安装代码格式化工具。 -## 16.1.7 C# 环境 +### 7. C# 环境 1. 下载并安装 [.Net 6.0](https://dotnet.microsoft.com/en-us/download) 。 2. 在 VSCode 的插件市场中搜索 `C# Dev Kit` ,安装 C# Dev Kit ([配置教程](https://code.visualstudio.com/docs/csharp/get-started))。 3. 也可使用 Visual Studio([安装教程](https://learn.microsoft.com/zh-cn/visualstudio/install/install-visual-studio?view=vs-2022))。 -## 16.1.8 Swift 环境 +### 8. Swift 环境 1. 下载并安装 [Swift](https://www.swift.org/download/)。 2. 在 VSCode 的插件市场中搜索 `swift` ,安装 [Swift for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang)。 -## 16.1.9 Dart 环境 +### 9. Dart 环境 1. 下载并安装 [Dart](https://dart.dev/get-dart) 。 2. 在 VSCode 的插件市场中搜索 `dart` ,安装 [Dart](https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code) 。 -## 16.1.10 Rust 环境 +### 10. Rust 环境 1. 下载并安装 [Rust](https://www.rust-lang.org/tools/install)。 2. 在 VSCode 的插件市场中搜索 `rust` ,安装 [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)。 diff --git a/chapter_backtracking/backtracking_algorithm.md b/chapter_backtracking/backtracking_algorithm.md index e92284493..3e6117197 100644 --- a/chapter_backtracking/backtracking_algorithm.md +++ b/chapter_backtracking/backtracking_algorithm.md @@ -1667,6 +1667,8 @@ comments: true 为了更清晰地分析算法问题,我们总结一下回溯算法中常用术语的含义,并对照例题三给出对应示例。 +
表 13-1 常见的回溯算法术语
+表 13-1 数组与链表的效率对比
+表 13-2 数组与链表的效率对比
图 10-2 binary_search_step1
+图 10-2 二分查找流程
值得注意的是,由于 $i$ 和 $j$ 都是 `int` 类型,**因此 $i + j$ 可能会超出 `int` 类型的取值范围**。为了避免大数越界,我们通常采用公式 $m = \lfloor {i + (j - i) / 2} \rfloor$ 来计算中点。 @@ -332,9 +332,9 @@ comments: true } ``` -时间复杂度为 $O(\log n)$ 。每轮缩小一半区间,因此二分循环次数为 $\log_2 n$ 。 +**时间复杂度 $O(\log n)$** :在二分循环中,区间每轮缩小一半,循环次数为 $\log_2 n$ 。 -空间复杂度为 $O(1)$ 。指针 $i$ 和 $j$ 使用常数大小空间。 +**空间复杂度 $O(1)$** :指针 $i$ 和 $j$ 使用常数大小空间。 ## 10.1.1 区间表示方法 diff --git a/chapter_tree/avl_tree.md b/chapter_tree/avl_tree.md index 397697201..9ae464086 100644 --- a/chapter_tree/avl_tree.md +++ b/chapter_tree/avl_tree.md @@ -26,7 +26,7 @@ AVL 树既是二叉搜索树也是平衡二叉树,同时满足这两类二叉 ### 1. 节点高度 -在操作 AVL 树时,我们需要获取节点的高度,因此需要为 AVL 树的节点类添加 `height` 变量。 +由于 AVL 树的相关操作需要获取节点高度,因此我们需要为节点类添加 `height` 变量。 === "Java" diff --git a/chapter_tree/binary_search_tree.md b/chapter_tree/binary_search_tree.md index 28f8c3f51..0dc88e977 100755 --- a/chapter_tree/binary_search_tree.md +++ b/chapter_tree/binary_search_tree.md @@ -738,15 +738,15 @@ comments: true 如图 7-19 所示,当待删除节点的度为 $0$ 时,表示该节点是叶节点,可以直接删除。 - + -图 7-19 在二叉搜索树中删除节点(度为 0)
+图 7-19 在二叉搜索树中删除节点(度为 0 )
如图 7-20 所示,当待删除节点的度为 $1$ 时,将待删除节点替换为其子节点即可。 - + -图 7-20 在二叉搜索树中删除节点(度为 1)
+图 7-20 在二叉搜索树中删除节点(度为 1 )
当待删除节点的度为 $2$ 时,我们无法直接删除它,而需要使用一个节点替换该节点。由于要保持二叉搜索树“左 $<$ 根 $<$ 右”的性质,**因此这个节点可以是右子树的最小节点或左子树的最大节点**。 @@ -756,7 +756,7 @@ comments: true 2. 将 `tmp` 的值覆盖待删除节点的值,并在树中递归删除节点 `tmp` 。 === "<1>" -  +  === "<2>"  @@ -767,7 +767,7 @@ comments: true === "<4>"  -图 7-21 二叉搜索树删除节点示例
+图 7-21 在二叉搜索树中删除节点(度为 2 )
删除节点操作同样使用 $O(\log n)$ 时间,其中查找待删除节点需要 $O(\log n)$ 时间,获取中序遍历后继节点需要 $O(\log n)$ 时间。