Computer ScienceData StructuresMedium

AVL Tree

Also known as:Adelson-Velsky and Landis treeHeight-balanced BST

An AVL tree is a self-balancing binary search tree in which the difference in heights between the left and right subtrees (the balance factor) of any node is at most 1. Named after its inventors Adelson-Velsky and Landis (1962), it was the first self-balancing BST ever invented. The tree automatically performs rotations (single or double) during insertions and deletions to maintain balance, guaranteeing O(log n) time for all operations.

AVL Tree Rotation Types and When They Are Applied

Rotation TypeConditionStepsBalance Restored
Left Rotation (LL)Right-heavy subtreePivot right child upYes
Right Rotation (RR)Left-heavy subtreePivot left child upYes
Left-Right Rotation (LR)Left child is right-heavyLeft rotate child, then right rotate rootYes
Right-Left Rotation (RL)Right child is left-heavyRight rotate child, then left rotate rootYes

Interactive Tools

CS USF — AVL Tree Visualization

Open Tool

Visualgo — AVL Tree

Open Tool

Brilliant.org — AVL Trees

Open Tool
An AVL tree showing rotations to maintain balance after insertions

Wikimedia Commons, CC BY-SA

Related Terms

The name "AVL" is an acronym derived from the surnames of its Soviet inventors, Georgy Adelson-Velsky and Evgenii Landis, who published the structure in their 1962 paper "An algorithm for the organization of information."

avlbalanced-treeself-balancingrotationsdata-structurebst