In an AVL tree, what is the maximum difference in height between the left and right subtrees of a node?
a) 1
b) 2
c) 3
d) No limit
Answer:
a) 1
Explanation:
In an AVL tree, the maximum difference in height between the left and right subtrees of any node is 1. This condition ensures that the tree remains balanced, keeping the height logarithmic with respect to the number of nodes.
When the balance factor of a node (the difference in heights of its subtrees) exceeds 1, the tree is rebalanced using rotations. These rotations restore the balance factor to either 0, -1, or 1.
The AVL tree provides logarithmic time complexity for insertion, deletion, and search operations, making it efficient for maintaining sorted data.
Reference:
DSA (Data Structures and Algorithms) MCQ Questions and Answers