Professional Documents
Culture Documents
14
LEARNING OUTCOMES
By the end of this topic, you should be able to:
1. Explain the concept of trees;
2. Distinguish different types of trees by identifying their
characteristics; and
3. Apply the concept of tree isomorphism.
X INTRODUCTION
A type of graph that is exceptionally useful in a variety of applications in
Information Technology is tree. For example, trees are being used to represent
data structure. Other examples where trees are useful are in decision making
(by using a special tree called decision tree) and in game theory (by making
use of the game tree). In this topic, we are going to discuss about tree.
SELF-CHECK 14.1
Example 14.1a
The following graph is a tree since there is a unique simple path from any
vertex in the graph to another vertex.
Example 14.1b
The following graphs are not trees since there is more than one path from some of
the vertex to another vertex.
Example 14.1c
ACTIVITY 14.1
Definition 14.2a: Let T be a tree with root v0. Suppose that x, y, and z are
vertices in T and that (v0, v1, .. vn) is a simple path in T. Then
(a) vn-1 is the parent of vn
(b) v0 . vn-1 are ancestors of vn
(c) vn is a child of vn-1
(d) If x is an ancestor of y, y is a descendant of x
(e) If x and y are children of z, x and y are siblings
(f) If x has no children, x is a terminal vertex (or a leaf)
(g) If x is not a terminal vertex, x is an internal (or branch) vertex
166 X TOPIC 14 TREE
Definition 14.2b: The subtree of T rooted at x is the graph with vertex set V
and edges set E, where V is x together with the descendant of x and
ACTIVITY 14.2
1. Answer the question below for the following tree
Can you represent your family tree by using binary tree concept? If
you think it is possible, how are you going to represent them?
TOPIC 14 TREE W 167
Binary trees are among the most important special types of rooted trees.
Definition 14.3a: A binary tree is a rooted tree in which each vertex has either
no children, one child, or two children. If a vertex has one child, that child is
designated as either a left child or a right child (but not both). If a vertex has
two children, one child is designated a left child and other child is designated a
right child.
Example 14.3a
Definition 14.3b: A full binary tree is a binary tree in which each vertex has
either two children or zero children.
Example 14.3b
Theorem 14.3b: If T is a full binary tree with i internal vertices, then T has i + 1
terminal vertices and 2i + 1 total vertices.
Example 14.3c
n + i = 2i + 1
so that i = n 1.
Example 14.3d
The binary tree in Example 14.3b, has height h = 3 and the number of terminals t = 8.
For this tree, the inequality (log2 t dh) becomes equality.
TOPIC 14 TREE W 169
ACTIVITY 14.3
The function f from the vertex set of the tree T1 shown in figure 14.7(a) to the
vertex set of the tree T2 shown in figure 14.7(b) defined by
f(a) = 1, f(b) = 3, f(c) = 2, f(d) = 4, f(e) = 5
is a one-to-one, onto function that preserves the adjacency relation. Thus,
the trees T1 and T2 are isomorphic.
170 X TOPIC 14 TREE
(a) (b)
As in the case of graphs, we can show that two trees are not isomorphic
if we can exhibit an invariant that the trees do not share.
Example 14.4b
The tree T1 and T2 in figure 14.8 are not isomorphic because T2 has a
vertex (x) of degree 3, but T1 does not have a vertex of degree 3.
Definition 14.4a: Let T1 be a rooted tree with root r1 and let T2 be a rooted tree
with root r2. The rooted trees T1 and T2 are isomorphic if there is a one to one,
onto function f from the vertex set of T1 to the vertex set of T2 satisfying the
following:
(a) Vertices v1 and v2 are adjacent in T1 if and only if the vertices f(vi) and f(vj)
are adjacent in T2.
(b) f(r1) = r2
We call the function f is an isomorphism.
Example 14.4c
Example 14.4d
The rooted trees T1 and T2 in figure 14.11 are not isomorphic since the root of T1
has degree 3 but the root of T2 has degree 2. These trees are isomorphic as free
trees. Each is isomorphic to the tree T2 of the following figure:
172 X TOPIC 14 TREE
Definition 14.4b: Let T1 be a binary tree with root r1 and let T2 be a binary tree
with root r1 and let T2 be a binary tree with root r2. The binary trees T1 and T2
are isomorphic if there is a one to one, onto function f from the vertex set of T1
to the vertex set of T2 satisfying the following:
(a) Vertices v1 and v2 are adjacent in T1 and if and only if the vertices f(vi) and
f(vj) are adjacent in T2.
(b) f(r1) = r2
(c) v is a left child of w in T1 if and only if f(v) is a left child of f(s) in T2.
(d) v is a right child of w in T1 if and only if f(v) is a left child of f(s) in T2.
Example 14.4e
The binary trees T1 and T2 in figure 14.12 are isomorphic. The isomorphism is f
(vi) = si for i = 1, 4.
Example 14.4e
The binary trees T1 and T2 in figure 14.13 are not isomorphic. The root v1 in T1 has
a right child, but the root s1 in T2 has no right child.
ACTIVITY 14.4
This is a companion website from Prentice Hall. The website contains online test
on this topic which consist of T/F question, homework starter and real
examples. You can answer the questions online and get the result instantly.