![]() |
VOOZH | about |
Table of Content
A Red-Black tree is a balanced binary search tree where each node has an extra bit for denoting the color of the node, either Red or Black.
Properties:
The AVL tree (named after inventors Adelson-Velskii and Landis) is a strictly balanced binary search tree.
Properties:
| Basis of Comparison | Red-Black Tree | AVL Tree |
| Balancing | Relaxed balancing. No path is more than twice as long as any other. | Strict balancing. Height difference between subtrees <= 1. |
| Search (Lookups) | Slower than AVL because the tree can be taller. | Faster than Red-Black because the tree is more compact. |
| Insertion/Deletion | Faster. Requires fewer rotations to maintain balance. | Slower. Requires more frequent and complex rotations. |
| Storage | Lower overhead. Needs only 1 bit per node for color. | Higher overhead. Needs to store the height/balance factor (integer) per node. |
| Rotations | Max 2 rotations for insertion; Max 3 for deletion. | Can require up to O(log n) rotations in the worst case. |
map, set) and Java (TreeMap), or the Linux kernel's process scheduler.