Basic graph theory: trees (CSCI 2824, Spring 2015)In this lecture, we will study trees:
TreesYou have most probably studied rooted trees and binary search trees as a data-structure for organizing lists of numbers and efficiently performing insertions and deletions. However a tree is a useful structure in many other parts of CS:
Let us start with the simplest kind of trees: unrooted and undirected trees. Definition
A (unrooted) tree is an undirected graph such that
A rooted tree is a fully connected, acyclic graph with a special node that is called the root of the tree. You may have studied rooted trees in your data structures class. With a root, it is possible to define a parent and children for each node. But without a root, we will regard the tree simply as a connected, acyclic graph. ExamplesHere are some examples of unrooted trees: Non-ExamplesThe following graph is not a tree. It has a cycle: Here is another example that has more than one maximal connected components and is not a tree: Properties of TreesLeaves of a TreeA leaf of an unrooted tree is a node that has a degree . Let us write down the leaves of the following tree examples: Leaves are . Leaves are . Leaves are . Claim Every tree has a leaf. Proof
If the tree just has one node, then it is trivially a leaf. If the tree has two nodes connected by an edge, both nodes are leaves. Let us focus on trees with three or more nodes. Let us assume that a tree that does not have a leaf exists. Therefore for every node in this tree . We are going to show that has a cycle, yielding a contradiction with the assumption that it is a tree. Start from any node in the tree and do a walk as follows:
Note that the walk above can be continued for arbitrarily many steps. However, since number of vertices is finite, the walk repeats a vertex. Let for some , . We can now conclude the existence of a cycle with in it. Therefore is not a tree, yielding a contradiction. Thus, we have concluded that every tree has a leaf. Number of EdgesClaim A tree with nodes has edges. Proof
Proof is by weak induction on the number of nodes . Base Case: Take any tree with node. There is just one such tree and it has edges. Inductive Hypothesis: Let us assume that all trees with nodes have edges. We will show that all trees with nodes have edges. Take some tree with nodes. It must have a leaf . Removing the leaf gives us a tree with nodes that must have edges in it. The leaf itself was connected to the rest of the tree by one edge. Therefore has edges. Number of LeavesClaim Any tree has at least two leaves. We will prove this in class by the following argument. We already know that any tree has at least one leaf. Proof
Let us assume that there is a tree with nodes and exactly one leaf .
Paths in TreesClaim Let and be two nodes in a tree. There is precisely one path from to in the tree. Argument in class Since the tree is connected component itself, there has to be at least one path from to . We will argue that having two distinct paths will necessarily imply that the tree has a cycle which will lead to a contradiction. |