Basic Tree Concept: Defining ancestors
data-structures, tree
Solution
E is not an ancestor of H. It's an uncle because it's a sibling of F, which is the parent of H.
F,C,A are ancestors of H. That's true.
G is not relevant to H at all.
Tree structure relationship notation can be found here (according to Wikipedia)
- A node's "parent" is a node one step higher in the hierarchy (i.e. closer to the root node) and lying on the same branch.
- "Sibling" ("brother" or "sister") nodes share the same parent node.
- A node's "uncles" are siblings of that node's parent.
- A node that is connected to all lower-level nodes is called an "ancestor". The connected lower-level nodes are "descendants" of the ancestor node.
Problem
What defines an ancestor? More specifically, would E be an ancestor to H? Or is it more simply that F,C,A are ancestors to H? Maybe even G? I would just like to clear up this simple concept.