mirror of
https://github.com/huihut/interview.git
synced 2024-03-22 13:10:48 +08:00
更新链式二叉树、平衡二叉树
This commit is contained in:
parent
e8f140649e
commit
72327ba94b
23
README.md
23
README.md
|
@ -303,8 +303,31 @@ typedef struct BiTNode
|
|||
|
||||
#### 平衡二叉树(AVL树)
|
||||
|
||||
##### 性质
|
||||
|
||||
* | 左子树树高 - 右子树树高 | <= 1
|
||||
* 平衡二叉树必定是二叉搜索树,反之则不一定
|
||||
* 最小二叉平衡树的节点的公式:`F(n)=F(n-1)+F(n-2)+1` (1是根节点,F(n-1)是左子树的节点数量,F(n-2)是右子树的节点数量)
|
||||
|
||||
![](images/Self-balancingBinarySearchTree.png)
|
||||
|
||||
##### 最小失衡树
|
||||
|
||||
平衡二叉树插入新结点导致失衡的子树
|
||||
|
||||
调整:
|
||||
|
||||
* LL型:根的左孩子右旋
|
||||
* RR型:根的右孩子左旋
|
||||
* LR型:根的左孩子左旋,再右旋
|
||||
* RL型:右孩子的左子树,先右旋,再左旋
|
||||
|
||||
#### 红黑树
|
||||
|
||||
##### 应用
|
||||
|
||||
* 关联数组:如STL中的map、set
|
||||
|
||||
#### B树
|
||||
|
||||
#### B+树
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
BIN
images/Self-balancingBinarySearchTree.png
Normal file
BIN
images/Self-balancingBinarySearchTree.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.4 KiB |
Loading…
Reference in New Issue
Block a user