What is the balance factor of a node in an AVL tree?

Options

  • A. Height of left subtree minus height of right subtree
  • B. Height of right subtree minus height of left subtree only
  • C. Number of children of the node
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

A. Height of left subtree minus height of right subtree

Detailed Explanation

The balance factor of an AVL tree node is commonly defined as height(left subtree) - height(right subtree). For a valid AVL tree, the balance factor of every node must be -1, 0, or +1. A factor of 0 means both subtrees have equal height, while +1 means the left subtree is one level taller and -1 means the right subtree is one level taller. Values outside this range require rebalancing.