AI engineering glossary · Data structures algorithms
What is red-black tree?
Red-black tree: A self-balancing binary search tree in which each node is coloured red or black under rules that keep the longest path at most twice the shortest. It guarantees O(log n) operations with fewer rotations than an AVL tree on updates.
Red-black tree: an example
Ordered map implementations in some standard libraries use red-black trees so inserts and lookups stay logarithmic even for sorted input.
Related terms
More Data structures algorithms terms
- Reservoir sampling
- Segment tree
- Selection sort
- Separate chaining
- Shortest path
- Sliding window
- Sorting
- Space complexity
Where you learn it
Red-black tree is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.