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
?