CSCE 235

Handout 22: Trees

Assigned April 23, 2003 

 

Basic Definitions

 

Definition 1.  A tree is a connected undirected graph with no simple circuits.

 

A group of trees is a forest.

 

THEOREM 1.  An undirected graph is a tree if and only if there is a unique simple path between any two of its vertices.

 

Definition 2.  A rooted tree is a tree in which one vertex has been designated as the root and every edge is directed away from the root.

 

If v is a vertex in T other than the root, the parent of v is the unique vertex u such that there is a directed edge from u to v.  When u is the parent of v, v is called a child of u.  Vertices with the same parent are called siblings.  The ancestors of a vertex other than the root are the vertices in the path from the root to this vertex, excluding the vertex itself and including the root (that is, its parent, its parent’s parent, and so on, until the root is reached).  The descendants of a vertex v are those vertices that have v as an ancestor.  A vertex of a tree is called a leaf if it has no children.  Vertices that have children are called internal vertices.  The root is an internal vertex unless it is the only vertex in the graph, in which case it is a leaf. If a is a vertex in a tree, the subtree with a as its root is the subgraph of the tree consisting of a and its descendants and all edges incident to these descendants.

 

Definition 3.  A rooted tree is called an m-ary tree if every internal vertex has no more than m children.  The tree is called a full m-ary tree if every internal vertex has exactly m children.  An m-ary tree with m = 2 is called a binary tree.

 

An ordered rooted tree is a rooted tree where the children of each internal vertex are ordered.  Thus, we have left child, right child, left subtree, and right subtree. 

 

Properties

 

THEOREM 2.  A tree with n vertices has n-1 edges. 

 

THEOREM 3.  A full m-ary tree with i internal vertices contains n = mi + 1 vertices. 

 

THEOREM 4.  A full m-ary tree with (a) n vertices has  internal vertices and  leaves, (b) i internal vertices has n = mi + 1 vertices and  leaves, and (c) l leaves has  vertices and  internal vertices.

 

Proof:  Let n represent the number of vertices, i the number of internal vertices, and l the number of leaves.  The three parts of the theorem can all be proved using the equality given in THEOREM 3, that is, has n = mi + 1, together with the equality n = l + i, which is true because each vertex is either a leaf or an internal vertex.  Solving for i in n = mi + 1 gives .  Then inserting this expression for i into the equation n = l + i shows that .

 

The level of a vertex v in a rooted tree is the length of the unique path from the root to this vertex.  The level of the root is defined to be zero.  The height of a rooted tree is the maximum of the levels of vertices.  The height of a rooted tree is the length of the longest path from the root to any vertex.

 

A rooted m-ary tree of height h is balanced if all leaves are at levels h or h-1. 

 

THEOREM 5.  There are at most  leaves in an m-ary tree of height h.  Proof is based on induction, straightforward.

 

COROLLARY 1.  If an m-ary tree of height h has l leaves, then .  If the m-ary tree is full and balanced, then

 

Based on (Rosen 2003).