# Does a tree node have an ancestor?

Below is a rooted tree, where any node `C` except root has one parent `P`

Ancestors of a node `C` are the nodes on path from `C` to `root`, including `P`,`P`'s parent,`P`'s grandparent, .... till `root`.

My understanding is, Tree is just a set of nodes & edges that connect these nodes. Between any two nodes there is exactly one single path. A tree does not need to have any `root`.

Any rooted tree MUST be a tree but any tree may not be a rooted tree.

In the below tree(not a rooted tree),

--

My understanding is, parent-child, depth, height, subtree, siblings, leaf-node concepts are only applied to rooted trees.

If no, then,

Is `X` a parent of `Y`? If yes, Who are the ancestors of `Y`?

• As far as I know your second example is not a tree. In a tree, each node has only one parent, no connection between siblings (no horizontal lines) and 0 or more children. Your second example is a graph. Commented Sep 15, 2015 at 8:30
• Mandrill, the second example is still a tree. A tree is an undirected graph in which there exists exactly one path between any two vertices. Your comments of having a single parent and no connection between siblings do not hold true as the parent ancestor relationship applies only for rooted trees. Commented Sep 15, 2015 at 8:40
• In fact, in some contexts people just speak of "trees" when they mean rooted trees. Therefore, when you read an article by an arbitrary author, make sure you and he means the same. Commented Sep 15, 2015 at 19:07