Red Black Tree Visualizer

Insert values into a red black tree, inspect recoloring and rotation logs, and compare the final balanced shape against a regular binary search tree.

Nodes
7
Root
20
Height
3
Black h
3

Insertion order

Insert or search

Red black tree diagram

Inserted 30 as a red child of 20.

Black Red Active
Red black treeRed black tree with 7 nodes, root 20, and black height 3.1red5black10red15black20black25red30black

Rotation log

Inserted 30 as a red child of 20.

Left rotate at 10.

Inserted 15 as a red child of 10.

Recolor parent 10, uncle 30, and grandparent 20.

Inserted 25 as a red child of 30.

Inserted 5 as a red child of 10.

Inserted 1 as a red child of 5.

Recolor parent 5, uncle 15, and grandparent 10.

Color summary

Black nodes
4
Red nodes
3

Red black insertion keeps the tree roughly balanced by preventing adjacent red nodes and keeping every root-to-leaf path at the same black height.

What is a Red Black Tree Visualizer?

A red black tree visualizer shows a self-balancing binary search tree with red and black node colors. Insertions may trigger recoloring and rotations to keep the tree height controlled.

This tool visualizes insertion order, search paths, node colors, rotations, recoloring, and black height checks.

For the full cluster of related tools, browse the Data Structure Visualizers hub.

How to use this red black tree visualizer

  • Paste values such as [10, 20, 30, 15, 25].
  • Build the red black tree.
  • Insert one value at a time.
  • Search for a value to highlight the path.
  • Read the operation log for recoloring and rotation cases.

Red black trees are binary search trees with extra color rules that keep the tree approximately balanced.

Red black tree vs AVL tree

AVL trees keep stricter height balance. Red black trees usually allow slightly looser balance but can need fewer rotations during updates.

Compare this page with the AVL Tree Visualizer and Binary Search Tree Visualizer to see the difference.

Frequently Asked Questions

What color is the root in a red black tree?
The root is always black.
What happens when a red node has a red parent?
The tree fixes the violation with recoloring, rotation, or both.
Does this tool support deletion?
This visualizer focuses on insertion, search, colors, and rotations because red black deletion has several additional cases.
Can I paste my own values?
Yes. Paste numbers as an array, comma-separated list, or space-separated list.

Related tools