mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-13 18:00:18 +08:00
build
This commit is contained in:
@@ -30,7 +30,7 @@ status: new
|
||||
- 前序遍历:`[ 根节点 | 左子树 | 右子树 ]` ,例如上图 `[ 3 | 9 | 2 1 7 ]` 。
|
||||
- 中序遍历:`[ 左子树 | 根节点 | 右子树 ]` ,例如上图 `[ 9 | 3 | 1 2 7 ]` 。
|
||||
|
||||
以上图数据为例,我们可以通过以下步骤得到上述的划分结果:
|
||||
以上图数据为例,我们可以通过下图所示的步骤得到划分结果:
|
||||
|
||||
1. 前序遍历的首元素 3 是根节点的值。
|
||||
2. 查找根节点 3 在 `inorder` 中的索引,利用该索引可将 `inorder` 划分为 `[ 9 | 3 | 1 2 7 ]` 。
|
||||
|
||||
Reference in New Issue
Block a user