Module 8: Trees and Graphs
Theme 1: Basic Properties of Trees
A (rooted)
tree
is a ﬁnite set of nodes such that
there is a specially designated node called the
root
.
the remaining nodes are partitioned into
disjoint sets
such that each of these
sets is a tree. The sets
are called
subtrees
,and
the degree of the root.
The above is an example of a recursive deﬁnition, as we have already seen in previous modules.
Example 1
: In Figure 1 we show a tree rooted at
with three subtrees
,
and
rooted at
,
and
, respectively.
We now introduce some terminology for trees:
A tree consists of
nodes
or
vertices
that store information and often are labeled by a number
or a letter. In Figure 1 the nodes are labeled as
.
An
edge
is an unordered pair of nodes (usually denoted as a segment connecting two nodes).
For example,
is an edge in Figure 1.
The number of subtrees of a node is called its
degree
. For example, node
is of degree three,
while node
is of degree two. The maximum degree of all nodes is called the degree of the
tree.
A
leaf
or a
terminal node
is a node of degree zero. Nodes
and
are leaves
in Figure 1.
A node that is not a leaf is called an
interior node
or an
internal node
(e.g., see nodes
and
).
Roots of subtrees of a node
are called
children
of
while
is known as the
parent
of its
children. For example,
and
are children of
, while
is the parent of
and
.
Children of the same parent are called
siblings
. Thus
are siblings as well as
and
are siblings.
The
ancestors
of a node are all the nodes along the path from the root to that node. For example,
ancestors of
are
and
.
The
descendants
of a node are all the nodes along the path from that node to a terminal node.
Thus descendants of
are
and
.
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentC
G
A
E
F
B
L
K
J
I
H
D
M
T
1
T
2
T
3
Figure 1: Example of a tree.
The
level
of a node is deﬁned by letting the root to be at level zero
1
, while a node at level
has
children at level
. For example, the root
in Figure 1 is at level zero, nodes
are
at level one, nodes
ate level two, and nodes
are at level three.
The
depth
of a node is its level number. The
height
of a tree is the maximum level of any
node in this tree. Node
is at depth two, while node
at depth three. The height of the tree
presented in Figure 1 is three.
A tree is called a
ary tree
if every internal node has no more than
children. A tree is called
a
full
ary tree
if every internal node has
exactly
children. A
complete tree
isafulltreeup
the last but one level, that is, the last level of such a tree is not full. A
binary tree
is a tree with
. The tree in Figure 1 is a
ary tree, which is neither a full tree nor a complete tree.
An
ordered rooted tree
is a rooted tree where the children of each internal node are ordered.
We usually order the subtrees from left to right. Therefore, for a binary (ordered) tree the
subtrees are called the
left subtree
and the
right subtree
.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 W.Szpankowski
 Graph Theory, Tree traversal

Click to edit the document details