Tree height measures the longest downward route from the root to a node. A height of 2 means every node is at most two steps from the root. section 8.3
Two trees, seven nodes
Two trees can contain the same seven nodes yet have very different heights. A short tree has height 2, while a tree whose nodes form a line has height 6. The short tree supports O(log n) searches; the tall tree behaves like a linked list and takes O(n). section 8.3
Height connects tree shape to search speed. A binary search tree is fastest when its height stays O(log n); inserting values in increasing order can stretch it to O(n). Balancing keeps the tree short. section 8.2 section 8.3
AVL trees use height-related information to decide when to rebalance:
- Store each node’s height or its balance factor; either is sufficient. section 8.6
- After insertion, update the height and balance factor for the inserted node’s ancestors. section 8.6
- Rotate when the balance factor falls below −1 or rises above 1. section 8.6
Compare the shapes and heights of equally sized trees visually. section 8.3


