RedBlackTree¶
约 195 个字 预计阅读时间 1 分钟
Definition
- Every node is either red or black.
- The root is black.
- Every leaf (NIL) is black.
- if a node is red, then both its children are black.
- For each node, all simple paths from the node to descendant leaves contain the same number of black nodes.
Property
一个有 \(N\) 个内部节点(不包括叶子结点)的红黑树,其高度最大为 \(2\log_2 (N+1)\)。
the proof of the property
- 首先我们有 \(N \geq 2^{bh}-1\),也就是 \(bh \leq \log_2 (N+1)\);
- 然后显然有 \(2 bh(Tree) >= h(Tree)\)
B+ Tree¶
更一般地来说,B+ 树满足如下性质:
property of B+ Tree
@cy's PPT
- The root is either a leaf or has between \(2\) and \(M\) children.
- All nonleaf nodes (except the root) have between \(\lceil M/2 \rceil\) and M children.
- All leaves are at the same depth.
Assume each nonroot leaf also has between \(\lceil M/2 \rceil\) and \(M\) children.