An ancestor is a node on the path from the root to another node. The root is an ancestor of every other node, while the second node is its descendant. section 11.2
Ancestor relationships clarify how nodes connect in a tree:
- A node can be an ancestor through several levels, not only through a direct parent link. section 11.2
- Every node has the root as a shared ancestor, and each child begins a subtree containing its descendants. section 11.2
- In a binary search tree, ancestor constraints narrow the values that can appear in a node’s subtrees, guiding search decisions. section 11.8
Tracing a path
If the path from the root to node 7 passes through node 8, then 8 is an ancestor of 7. During a binary search, constraints inherited from ancestors can show that a target belongs only in one subtree. section 11.2 section 11.8
Use the tree figure to follow root-to-node paths and identify ancestor relationships visually. section 11.2
