AVL-tree,
B-tree, ...
AVL-tree,
rotation schemes (single rotation, double rotation).
Multi-way search tree, B-tree. Properties and updating operations:
insert, overflow detection, split, remove, underflow detection,
fusion (merge).
Binomial tree, red-black tree.
AVL (Adelson-Velski, Landis)
tree in a binary search tree where:
- Left and right subtrees are AVL trees
and difference of heights of subtrees is less or equal
to one level.
- Empty tree is an AVL tree.
Searching does not change the
tree and the usual binary tree search can be applied.
Adding and deleting must take care of balancing the tree to keep
AVL property satisfied.
Single rotation. Read the in-order sequence of both
trees: I a II B III to justify this operation.
Difference 2 becomes difference 0.
The mirror of this scheme is also applicable: III b II a I .
Double rotation. I a II c III b IV. Difference
2 becomes difference 1.
Mirror: IV b III c II a I.
B-tree
Binary search tree has one key
in each node and maximum two subtrees for each node.
Multi-way search tree has 1 .. m-1 keys in each node and maximum
m subtrees for each node (m > 1 is a constant).
Multi-way search tree of order m (m-way search tree):
- is empty or
- has a root node with j (0 < j < m
) keys and j+1 subtrees, that are ALL empty or ALL non-empty
m-way search trees with the following key properties:
- keys of the root node are ordered: k1
<= k2 <= ... <= kj
- for subtrees T0, T1, ... , Tj
the following three conditions hold:
a) for all keys k in subtree T0
: k <= k1
b) for all keys k in subtree Ti
(0<i<j) : ki <= k <= ki+1
c) for all keys k in subtree Tj : k
>= kj
B-tree of order m (Bayer,
McGreigh) is a m-way search tree where:
- all leaves are on the same level;
- leaves do not contain keys (empty);
- root node has 2 .. m subtrees;
- all other intermediate nodes have from t=ceil[m/2]
(t>=2) to m subtrees.
Binomial tree
Height O(log n).
Binomial tree Bk is defined by recursion:
- B0 is a one node tree;
- Bk (k>0) is constructed from two trees Bk-1,
second tree is added to the first tree as the first child of
the root.
Binomial tree Bk has
the following properties:
- height of a tree is k
- number of nodes is 2k
- root node has the greatest number of subtrees: Bk-1,
Bk-2, ..., B0
Red-black tree
Similar to AVL-tree, but more
relaxed and still balanced.
Each node of a binary search tree is red or black.
Red-black tree is a BST where:
- Each node is either red or black
- The root node is black
- All the leaves are black (empty nodes)
- All children of the red node are black
- Each path from the root node to any leaf node has the
same number of black nodes in it
Maximal height: 2 log (n+1)
All operations take O(log n).
Slides
Jaanus Pöial