Bifalgorithm post · Brisk · Chapter 1
What are the main terms used to describe rooted trees?
What are the main terms used to describe rooted trees? (Brisk · Chapter 1) — "Rooted tree terminology\n\nRooted trees carry with them a number of terms. I’ll u…
Ideas in this flowchart
- Rooted tree terminology
- Root: the top node of a tree. In the example, A is the root; every nonempty tree has one, while the empty tree has no nodes.
- Parent: the node immediately above another node. Every node except the root has exactly one parent; A has none.
- Child: a node connected directly below another node. A’s children are F and B, C’s are D and E, and E has none.
- Sibling: a node with the same parent. E and D are siblings, as are B and F; the other nodes have no siblings.
- Ancestor: a node’s parent, grandparent, and earlier predecessors up to the root. E’s ancestors are C, B, and A; F is not an ancestor of C.
- Descendant: a node’s children, grandchildren, and later successors down to the leaves. B’s descendants are C, D, and E; A’s are F, B, C, D, and E.
- Leaf: a node with no children. F, D, and E are leaves; in a one-node tree, the root can also be a leaf.
- Internal node: any node that is not a leaf. In the example, A, B, and C are internal nodes.
- Depth: the distance from a node to the root, measured in nodes; the root has depth 0. B has depth 1 and E has depth 3.
- Height: the maximum depth of any node in the tree. The example has height 3; a one-node tree has height 0, and the empty tree has height −1.
