(Finally) The end of the course!
(2, 4) tree
Multi-way search tree:
an ordered tree such that:
- each interval node has at least two children and stores d-1 key-element items , where is the number of children
- for a node with children
storing keys
- keys in the subtree of are less than
- keys in the subtree of are between and (i=2,…d-1)
- keys in the subtree of are greater than
An inorder traversal of a multi-way search tree visits the keys in increasing order.
A (2, 4) Tree:
- Node-Size property: each internal node has at most 4 children
- Depth property: all the external nodes have the same depth.
Theorem: Height of a (2,4) tree is O(log N)
relation with Red-Black tree:
2–3–4 trees are an isometry of red–black trees, meaning that they are equivalent data structures. In other words, for every 2–3–4 tree, there exists at least one red–black tree with data elements in the same order. Moreover, insertion and deletion operations on 2–3–4 trees that cause node expansions, splits and merges are equivalent to the color-flipping and rotations in red–black trees. Introductions to red–black trees usually introduce 2–3–4 trees first, because they are conceptually simpler. 2–3–4 trees, however, can be difficult to implement in most programming languages because of the large number of special cases involved in operations on the tree. Red–black trees are simpler to implement,[2] so tend to be used instead.
Reference
https://en.wikipedia.org/wiki/2%E2%80%933%E2%80%934_tree
Red-Black Tree
A red-black tree is a representation of a (2, 4) tree by means of a binary tree whose nodes are colored red or black.
In comparision with its associated (2, 4) tree, a red-black tree has:
- Same logarithmic time performance
- Simpler implementation with a single node type.
Property:
- Root is black
- Leaf is black
- Children of a red node is black
- all leaves have the same black depth