mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-01 01:54:24 +00:00
Update the book based on the revised second edition (#1014)
* Revised the book * Update the book with the second revised edition * Revise base on the manuscript of the first edition
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
1. 前序遍历的首元素 3 是根节点的值。
|
||||
2. 查找根节点 3 在 `inorder` 中的索引,利用该索引可将 `inorder` 划分为 `[ 9 | 3 | 1 2 7 ]` 。
|
||||
3. 根据 `inorder` 划分结果,易得左子树和右子树的节点数量分别为 1 和 3 ,从而可将 `preorder` 划分为 `[ 3 | 9 | 2 1 7 ]` 。
|
||||
3. 根据 `inorder` 的划分结果,易得左子树和右子树的节点数量分别为 1 和 3 ,从而可将 `preorder` 划分为 `[ 3 | 9 | 2 1 7 ]` 。
|
||||
|
||||

|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
| 左子树 | $i + 1$ | $[l, m-1]$ |
|
||||
| 右子树 | $i + 1 + (m - l)$ | $[m+1, r]$ |
|
||||
|
||||
请注意,右子树根节点索引中的 $(m-l)$ 的含义是“左子树的节点数量”,建议配合下图理解。
|
||||
请注意,右子树根节点索引中的 $(m-l)$ 的含义是“左子树的节点数量”,建议结合下图理解。
|
||||
|
||||

|
||||
|
||||
|
||||
Reference in New Issue
Block a user