Lesson 153

AVL Trees

Balance Factor · Rotations · O(log n)

1:00

How AVL trees use balance factors and rotations to keep a BST at O(log n) height — covering all four imbalance cases, the Fibonacci-tree height proof, and AVL vs red-black tradeoffs.

By the end, you can

  • Explain why sorted insertions degrade a BST to O(n) and why that motivates self-balancing.
  • Define balance factor, compute it by hand for any node, and state the AVL invariant.
  • Identify which of the four imbalance cases (LL, RR, LR, RL) applies from the balance factors of a node and its child.
  • Describe the rotation(s) needed for each case and trace the resulting node positions.
  • State the rebalancing cost difference between AVL insert (at most one rotation) and AVL delete (up to O(log n) rotations).
  • Explain the Fibonacci-tree argument for why AVL height is O(log n).
  • Compare AVL and red-black trees and choose the right one for a given workload.
Up next in Advanced Data Structures
Questions or feedback?