Tree terminology: some definitions
-
Children of a node P: the set of nodes that have P as parent
-
Descendant of a node P:
-
If a node C is a child of P, then C is a descendant of P
-
If a node C is a child of a descendant of P, then C is a descendant of P
-
Ancestor of a node C: if C is a descendant of P, then P is an ancestor of C
-
Root of a tree: the unique node in the tree with no parent
-
Leaves of a tree: the set of nodes with no children
-
Subtree:
-
The empty tree is a subtree of every tree
-
Any node of a tree together with its descendants is a subtree of the tree
-
Level or depth of a node (using ‘zero-based’ counting):
-
The level of the root is 0.
-
The level of any non-root node is 1 + the level of its parent (this is equal to the number of edges on the path from the root to the node)
-
Height of a node: the height of a node is the number of edges on the longest path from the node to a leaf
-
Height
of a tree: the height of the root of the tree
CONTENTS PREVIOUS NEXT