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.

Level: advancedTopic: Data structures algorithms

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

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.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.