mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-08 05:26:07 +00:00
build
This commit is contained in:
@@ -11,7 +11,7 @@ status: new
|
||||
|
||||

|
||||
|
||||
<p align="center"> Fig. 构建二叉树的示例数据 </p>
|
||||
<p align="center"> 图:构建二叉树的示例数据 </p>
|
||||
|
||||
### 判断是否为分治问题
|
||||
|
||||
@@ -38,7 +38,7 @@ status: new
|
||||
|
||||

|
||||
|
||||
<p align="center"> Fig. 在前序和中序遍历中划分子树 </p>
|
||||
<p align="center"> 图:在前序和中序遍历中划分子树 </p>
|
||||
|
||||
### 基于变量描述子树区间
|
||||
|
||||
@@ -64,7 +64,7 @@ status: new
|
||||
|
||||

|
||||
|
||||
<p align="center"> Fig. 根节点和左右子树的索引区间表示 </p>
|
||||
<p align="center"> 图:根节点和左右子树的索引区间表示 </p>
|
||||
|
||||
### 代码实现
|
||||
|
||||
@@ -430,6 +430,8 @@ status: new
|
||||
=== "<10>"
|
||||

|
||||
|
||||
<p align="center"> 图:构建二叉树的递归过程 </p>
|
||||
|
||||
设树的节点数量为 $n$ ,初始化每一个节点(执行一个递归函数 `dfs()` )使用 $O(1)$ 时间。**因此总体时间复杂度为 $O(n)$** 。
|
||||
|
||||
哈希表存储 `inorder` 元素到索引的映射,空间复杂度为 $O(n)$ 。最差情况下,即二叉树退化为链表时,递归深度达到 $n$ ,使用 $O(n)$ 的栈帧空间。**因此总体空间复杂度为 $O(n)$** 。
|
||||
|
||||
Reference in New Issue
Block a user