Professional Documents
Culture Documents
Tree
14
LEARNING OUTCOMES
By the end of this topic, you should be able to: 1. 2. 3. Explain the concept of trees; Distinguish different types of trees by identifying their characteristics; and 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.
14.1
CONCEPT OF TREES
SELF-CHECK 14.1
Are trees that you learn in discrete mathematics the same with the trees that you see in real life?
Definition 14.1a: A tree T is a simple graph satisfying the following: If v and w are vertices in T, there is a unique simple path from v to w.
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.
Definition 14.1b: The rooted tree is a tree in which a particular vertex is designated the root.
File system in a computer can be organized into directories. A directory can contain both files and directories. The root directory.
ACTIVITY 14.1
1. Draw an example of a family tree. Draw the file system in your computer as a rooted tree.
2.
14.2
IMPORTANT TERMINOLOGY
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
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 E = {e | e is an edge on a simple path from x to some vertex in V}
ACTIVITY 14.2
1. Answer the question below for the following tree
Find the parent of c and of f. Find the ancestors of c and of j. Find the children of d and of e. Find the descendant of c and of e. Find the sibling of f and of h. Find the terminal vertices.
Draw the subtree of the tree in question 1 rooted at j. Draw the subtree of the tree in question 1 rooted at i.
3.
14.3
BINARY TREE
SELF-CHECK 14.2
Can you represent your family tree by using binary tree concept? If you think it is possible, how are you going to represent them?
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 In a binary tree of the following figure: x x x x x x vertex b is the left child of vertex a. vertex c is the right child of vertex a. vertex d is the right child of vertex b. vertex b has no left child. vertex e is the left child of vertex c. vertex c has no right child.
Definition 14.3b: A full binary tree is a binary tree in which each vertex has either two children or zero children.
A fundamental result about full binary trees is our next theorem 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 The graph of a single elimination tournament is a full binary tree. We show that if there are n contestants in a single elimination tournament, a total of n 1 matches are played. The number of contestants is the same as the number of terminal vertices, and the number of matches i is the same as the number of internal vertices. Thus, by theorem 14.3b n + i = 2i + 1 so that i = n 1. Theorem 14.3c: If a binary tree of height h has t terminal vertices, then log2 t d h
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 d h) becomes equality.
ACTIVITY 14.3
1. Draw a graph having the given properties or explain why no such graph exists. (a) (b) (c) 2. Full binary tree, 4 internal vertices, 5 terminal vertices Full binary tree, height = 3, 9 terminal vertices Full binary tree, height = 4, 9 terminal vertices
2. A binary tree T is balanced if for every vertex v in T, the heights of the left and right subtree of v differs by at most 1. State whether each tree is balanced or not.
14.4
TREE ISOMORPHISM
We have discussed the concept of graph isomorphism. Since a tree is basically a graph, the concept of graph isomorphism is similar to the concept of tree isomorphism.
14.4.1
Example 14.4a 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.
(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.
Example 14.4c The rooted trees T1 and T2 in figure 14.10 are isomorphic. An isomorphism is f(v1) = s1, f(v5) = s7, f(v2) = s3, f(v6) = s6, f(v3) = s4, f(v7) = s5 f(v4) = s2,
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:
14.4.3
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) (b) (c) (d) Vertices v1 and v2 are adjacent in T1 and if and only if the vertices f(vi) and f(vj) are adjacent in T2. f(r1) = r2 v is a left child of w in T1 if and only if f(v) is a left child of f(s) in T2. 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
1. Determine whether each pair of rooted trees is isomorphic. If the pair is isomorphic, specify an isomorphism. If the pair is not isomorphic, give an invariant that one tree satisfies but the other does not.
2.
Draw all the trees for the following condition: (a) (b) (c) (d) (e) nonisomorphic free trees having three vertices. nonisomorphic free trees having four vertices. nonisomorphic rooted trees having three vertices. nonisomorphic binary trees having four vertices. nonisomorphic full binary trees having seven vertices
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. URL: http://wps.prenhall.com/esm_goodaire_discrete_2/0%2C5290%2 %2C00.html C379767-