Skip to content

Commit b40c4eb

Browse files
committed
[docs update]修订关于节点深度的定义
1 parent f24de6c commit b40c4eb

File tree

1 file changed

+5
-1
lines changed
  • docs/cs-basics/data-structure

1 file changed

+5
-1
lines changed

docs/cs-basics/data-structure/树.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ tag:
3131
- **节点的层数** :节点的深度+1。
3232
- **树的高度** :根节点的高度。
3333

34+
> 关于树的深度和高度的定义可以看 stackoverflow 上的这个问题:[What is the difference between tree depth and height?](https://stackoverflow.com/questions/2603692/what-is-the-difference-between-tree-depth-and-height)
35+
3436
## 二叉树的分类
3537

3638
**二叉树**(Binary tree)是每个节点最多只有两个分支(即不存在分支度大于 2 的节点)的树结构。
3739

3840
**二叉树** 的分支通常被称作“**左子树**”或“**右子树**”。并且,**二叉树** 的分支具有左右次序,不能随意颠倒。
3941

40-
**二叉树** 的第 i 层至多拥有 `2^(i-1)` 个节点,深度为 k 的二叉树至多总共有 `2^k-1` 个节点
42+
**二叉树** 的第 i 层至多拥有 `2^(i-1)` 个节点,深度为 k 的二叉树至多总共有 `2^(k+1)-1` 个节点(满二叉树的情况),至少有 2^(k) 个节点(关于节点的深度的定义国内争议比较多,我个人比较认可维基百科对[节点深度的定义](https://zh.wikipedia.org/wiki/%E6%A0%91_(%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84)#/%E6%9C%AF%E8%AF%AD))。
43+
44+
![](https://guide-blog-images.oss-cn-shenzhen.aliyuncs.com/github/javaguide/image-20220119112736158.png)
4145

4246
### 满二叉树
4347

0 commit comments

Comments
 (0)