What is an AVL tree and why is it balanced?

A self-balancing binary search tree with height difference at most 1 between left and right subtrees, ensuring O(log n) height

An AVL tree is a binary search tree that automatically keeps itself balanced. The key idea is that for every node, the heights of its left and right subtrees differ by at most one. This constraint prevents the tree from becoming too tall on any path, which would otherwise slow operations. Because of this balance, the tree’s height grows only logarithmically with the number of nodes, ensuring search, insert, and delete can be performed in O(log n) time. When insertions or deletions cause a node to become unbalanced (its subtrees differ by more than one in height), rotations (single or double) are used to restore the balance while preserving the binary search tree order. This structure isn’t about leaves being at the same depth (that would describe a perfectly balanced or complete tree) and it isn’t a heap; its defining feature is maintaining the balance constraint with rotations to keep the height small.

A tree where all leaves are at the same depth and there are no duplicates

A binary search tree with no duplicates

A heap-ordered tree with all leaves at same depth

Want more questions?

All options are one-time payments.

$12.50

30 day premium pass

All the basics to get you started

  • Ad-free experience
  • View your previous attempt history
  • Mobile app access
  • In-depth explanations
  • 30 day premium pass access
$30.00 $87.50 usd

6 month DELUXE pass (most popular)

Everything with the 30 day premium pass FOR 6 MONTHS! & the ultimate digital PDF study guide (BONUS)

  • Everything included in the premium pass
  • $87.50 usd value for $30.00! You save $57.50!
  • + Access to the ultimate digital PDF study guide
  • + 6 months of premium pass access
  • + Priority support
$12.50 $18.99

Ultimate digital PDF study guide

For those that prefer a more traditional form of learning

  • Available for instant download
  • Available offline
  • Hundreds of practice multiple choice questions
  • Comprehensive content
  • Detailed explanations
Image Description
Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy