📘 Lesson 6 of 9 · Discrete Mathematics

🌳 Trees

A tree is a special type of graph with no cycles — a natural way to represent hierarchies, from family trees to file systems to decision-making processes.

Course progress: 67%

01 Key Concepts

Definition

A tree is a connected graph with no cycles. A tree with n vertices always has exactly n-1 edges.

Root, Parent, Child

In a rooted tree, one vertex is designated the root; every other vertex has exactly one parent and can have multiple children.

Leaf Node

A vertex with no children (degree 1 in an undirected sense, aside from the root).

Height and Depth

The depth of a node is its distance from the root; the height of the tree is the maximum depth of any node.

Binary Tree

A tree where every node has at most 2 children, commonly used in computer science for efficient searching and sorting.

Spanning Tree

A subgraph of a connected graph that includes every vertex, is itself a tree, and uses the minimum number of edges needed to stay connected.

02 Key Formulas

03 Solved Examples

Example 1 A tree has 8 vertices. How many edges does it have?
  1. Apply the rule: edges = n - 1 = 8 - 1.
Answer: 7 edges
Example 2 A tree has 12 edges. How many vertices does it have?
  1. Rearrange the rule: n = edges + 1 = 12 + 1.
Answer: 13 vertices
Example 3 In a rooted tree, node X has children Y and Z, and Y has child W. Find the depth of W (root has depth 0).
  1. The root is depth 0. If X is the root, X has depth 0.
  2. Y (child of X) has depth 1.
  3. W (child of Y) has depth 2.
Answer: Depth of W = 2

04 Practice Questions

1A tree has 6 vertices. Find the number of edges.
5
2A tree has 20 edges. Find the number of vertices.
21
3What is a 'leaf node'?
A node with no children
4What is the maximum number of children a node can have in a binary tree?
2
5What defines a tree, as opposed to a general graph?
It's connected and has no cycles

📄 Trees — Downloadable Worksheet

10 questions with a full answer key. Grab the PDF to print, or try the interactive version in your browser.