<DS/>DS_VISUALIZER
FoundationsOOPArraysLinked ListStacksQueuesTreesGraphsHashingStrings
exploreExplore
homechevron_rightTopicschevron_rightTreeschevron_rightAvl Tree
balance

TREES · AVL

AVL Tree

A BST that rotates itself back into balance — |bf| ≤ 1 everywhere.

Choose an operation

add_boxarrow_outward

Insertion

BST insert, then rotate the first ±2 node.

O(log n)O(log n)◍ 0/6
deletearrow_outward

Deletion

BST delete, then rebalance the whole path.

O(log n)O(log n)◍ 0/6
rotate_rightarrow_outward

Rotations

The four imbalance cases and their fixes.