Binary Search Tree vs. AVL Tree

Insert and remove the same values in both trees and compare their shapes and balancing behavior.

Operations are applied to both trees. Duplicate values are ignored. In the AVL tree, each node maintains a balance factor in the range −1 to +1.
Enter a value and choose Insert or Remove.

Binary Search Tree (BST)

No automatic balancing

AVL Tree

Self-balancing BST

What to observe

BST: insertion order can produce a skewed tree. Its height can become linear in the number of nodes.

AVL: after insertion and deletion, rotations restore the balance condition. Its height remains logarithmic in the number of nodes.

Balance factor: height(left subtree) − height(right subtree). The small number shown below each AVL node is its balance factor.

Operation history

  1. Both trees are empty.