Rooted Tree — Definition, Formula & Examples
A rooted tree is a tree (a connected graph with no cycles) in which one specific vertex has been designated as the root, giving the tree a natural hierarchy of parent and child vertices.
A rooted tree is an ordered pair where is a connected acyclic graph and is a distinguished vertex called the root. For every vertex , there exists a unique path from to . The depth of is the length of this path, and the height of the tree is .
How It Works
Choosing a root imposes a direction on every edge: away from the root toward the leaves. Each non-root vertex has exactly one parent — the vertex adjacent to on the unique path back to . The children of are all vertices whose parent is . A vertex with no children is called a leaf. This parent-child structure turns an undirected tree into a hierarchy, which is why rooted trees appear everywhere from file systems to parse trees in compilers.
Worked Example
Problem: A tree has vertex set and edge set . Root the tree at vertex . Determine the parent, children, depth, and height information.
Step 1: Identify the root and its children. Vertex is the root (depth 0). The vertices adjacent to are and , so the children of are .
Step 2: Move one level down. Vertices and both have depth 1. The parent of each is . Vertex is adjacent to and (besides its parent ), so . Vertex has no neighbors other than , so is a leaf.
Step 3: Vertices and each have parent and depth 2. Neither has any other neighbors, so both are leaves. The height of the tree is the maximum depth.
Answer: The rooted tree has root , internal vertices , leaves , and height 2.
Why It Matters
Rooted trees are the backbone of data structures in computer science — binary search trees, heaps, and tries are all rooted trees. In discrete mathematics courses, they appear in counting problems (Cayley's formula), recursive algorithms, and proofs by structural induction.
Common Mistakes
Mistake: Assuming a tree has a natural root. An unrooted tree is just a connected acyclic graph with no hierarchy; parent-child relationships only exist once you choose a root.
Correction: Always specify which vertex is the root before referring to parents, children, depth, or height. The same underlying tree can produce different rooted trees depending on the choice of root.
