In graph theory, trees represent one of the most vital subclasses of graphs, offering elegant mathematical structures and highly efficient algorithmic properties. This guide explores the formal definitions, theorems, and traversal behaviors of both free and rooted trees.
[Free Tree] [Rooted Tree (Root = A)]
1---2---3 (A) <-- Level 0
| / \
4 (B) (C) <-- Level 1
/ \ / \
5 6 (D) (E) <-- Level 2A tree is formally defined as an undirected simple graph that is both connected and acyclic (contains no cycles). A forest is a collection of one or more disjoint trees.
Trees possess highly restrictive topological configurations. The following mathematical equivalences define a tree:
Let be the statement that a tree with vertices has edges.
A rooted tree is a tree in which one vertex is designated as the root, and all edges are implicitly directed away from this root.
(Root: A) [Level 0]
/ \
(B) (C) [Level 1]
/ \ \
(D) (E) (F) [Level 2]Rooted trees are categorized by their branching factor.
[Full Binary Tree] [Non-Full Binary Tree]
(A) (A)
/ \ / \
(B) (C) (B) (C)
/ \ /
(D) (E) (D)For any full -ary tree, let:
These variables are constrained by the following structural formulas:
For ordered rooted trees, we must often visit each vertex systematically. The three classic depth-first traversal algorithms are defined recursively:
(Root)
/ \
[Left] [Right]Given the following ordered binary tree:
(A)
/ \
(B) (C)
/ \
(D) (E)| Traversal | Order of Vertices Visited | Description / Rule | | :--- | :--- | :--- | | Preorder | | Node is visited prior to its subtrees. | | Inorder | | Node is visited between its left and right subtrees. | | | | Node is visited after its subtrees. |
The structural properties of directed hierarchies depend on how nodes transition and reach one another.
A subset constitutes a node base if and only if it satisfies the following mathematical conditions:
A connected, undirected simple graph containing no cycles.
A tree in which one vertex is designated as the root, directing all edges away from it.
A rooted tree where every internal node has at most m children; it is full if every internal node has exactly m children.
An undirected graph is a tree if and only if there exists a unique simple path between any pair of its vertices.
Systematic methods (Preorder, Inorder, Postorder) for visiting all vertices of an ordered rooted tree exactly once.
Test your understanding with 5 questions
A tree T has exactly n vertices. How many edges does T contain?
Which of the following conditions is mathematically equivalent to saying an undirected graph G with n vertices is a tree?
A full binary tree has 15 internal vertices. How many leaves (terminal vertices) does it contain?
Which traversal strategy visits the root node last, after recursively visiting the subtrees?
Which of the following is NOT a necessary property of a node base S in a directed graph?
6 Modules
6 Modules