0% found this document useful (0 votes)
378 views11 pages

Understanding Rooted Trees in Graph Theory

This document defines and provides examples of rooted trees and binary trees in graph theory. It discusses key concepts such as the root, children, leaves, levels, height, and descendants of a rooted tree. It also defines full and complete binary trees. A forest is defined as a set of disjoint trees. Steps are provided to represent any tree or forest as a unique binary tree. An example shows how to draw a tree from a given relation and its corresponding binary tree representation.

Uploaded by

Gunjan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
378 views11 pages

Understanding Rooted Trees in Graph Theory

This document defines and provides examples of rooted trees and binary trees in graph theory. It discusses key concepts such as the root, children, leaves, levels, height, and descendants of a rooted tree. It also defines full and complete binary trees. A forest is defined as a set of disjoint trees. Steps are provided to represent any tree or forest as a unique binary tree. An example shows how to draw a tree from a given relation and its corresponding binary tree representation.

Uploaded by

Gunjan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Rooted Tree (A directed tree): A rooted tree is a tree in which a particular vertex is distinguished

trom the other vertices and this vertex is called the root. Rooted trees in
graph theory are drawn with tner
roots at the top.
The
1) level of any vertex in a rooted tree is the length of the path from that vertex to the root. The levelo
to be in
root
is 0. The verfex jmmediatty und he nrot ae Sald
leuel 1 2 s m
2) The height of a rooted tree is the maximum level to any vertex of the tree.

3) Given any vertex v of a rooted tree, the children of v are the vertices that are immediate adjacent to v.

4) A vertex v having no children is called a leaf (terminal vertex)

5) The depth of a vertex v in a tree is the length of the path from the root to v.
6) IE u has either one or two children, then u is called an internal vertex.
Consider the following rooted tree.
Example
Here a is the root b and e are the children of a, n and g are the children off.

Vertex: a b c
d ef 8 h ii k1m n
Level: 0 1
2 3 1 2 3 4 2|2 3 33 3
Here, height =
maximum level =
4 and d, k, 1, m, n, h, I are leaves.
rooted tree in Fig. 1
tree 4a
14.4.
Consider
the
a
Example 1.

b C

9 h
Fig. 14.4
(a) What is the root of T?
(b) Find the leaves and the internal vertices of T.
(c) What are the levels of c ande.
THE

Find the children ofc and e.


e) Eind the descendants of the vertices a and c.
ion.
Solution (a) Vertex a is
distinguished as the
is the root. only vertex located at the top of the
tree.
ThereThe leaves are
T h e r e f o r e ,

(b) The leaves those vertices that have no children. These are b, f, gg and
and h. The internal
The interna
are c, d and e.
vertices
veruThe of c ande are 1 and 2
levels

The children of are d and and respectively.


c
of are g and h. e e
The descendants of a are b, c, d, e, f, g, h. The
descendants of c are d, e, f. 8, h.
Rooted trees with the
property that all of their internal vertices have the same number of
:1dren are used in many problemS involving
DaGnition A rooted tree ic s searching, sorting and coding.
Binary Tree: A binary tree is a rooted tree in which each vertex has almost two children. Th.
2 children. Each child is referred
ildren. That is
tree contains 0, 1 or as either a left child or a
right child (not1 a
oinary
A full binary tree is a binary tree in which each vertex has exactly zero or two children
Example

A
Binary Tree
AMA
full binary tree

Example (31): Find the left and right children of 2 in the following figure. What are the lat
left and
right sub trees of 1?

86
10 11 2 13
Solution: The left and right children of 2 are 4 and 5 respectively. The following trees
represent tho lad
right sub trees of 1.
A. .. eft 10
sub-tree of 1 11
Commplete Right sub-tree of 1 613

Binary
Complete binary treeTree: If all
of
the leaves of
depth m. For
full a
binary trec
ree are at level m,
example consider the then such a tree is called
Aa following tree.

Here d, e, f, g 1, p
m, n,
binary tree. pare the leaves and
the
they all are at level 3 from the root
a. Hence this is
Forest: A set of
a
complete
disjoint trees is called a forest. For
example the following figure is a forest.

The following step gives every tree ora forest


Step (1): Delete all the edges unique binary tree representation.
a

originating in every vertex


Step (2): Draw edges from a vertex to the vertex on the except the left most edge.
Step (3): Choose the left child and right child of rightvertex
if any of them is at the same level.
any as follows. The left child is
the vertex
immediately below the given vertex and the right child is to the immediate right of the
same horizontal line. given vertex on the

Example (32): Draw a tree for the relation R = {(1,2), (1,3), (1, 4), (2, 5), (4, , (6, 7) ona set A - |1, 2, 3,
4,5, 6, 7). Also give the corresponding binary tree.
Solution: Given R = {(1, 2), (1, 3), (1, 4), (2, 5), (4, 6), (4, 7)}

A
11,2,3, 4, 5,6,71.
We observe that the vertex with highest number of edges is 1.
relation R is drawn below.
Hence we select 1 as the root. The required tree for the given

drawn beow:
ne corresponding binary tree is
3
34 -
Step (4):
Step (7 Step (2) Step(
5
AlHHance & Co.

183
Step (5): dlapaph Theory

Is required binary tree

Example (33): Let A {1, 2,3, 4, 5, 6, 7, 8, 9, 10),T {(2, 3), (2, 1), (4, 5), (4, 6),
=
=

9). (7, 10)1. Identify the root and show that T is a rooted tree. Also (5, 8), (6, 7. a
give the
correspondine
tree. onding bbinary
Solution: Given A {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} and T ={(2,3), (2, 1), (4, 5), (4, 6), (5,
8), (6,7), (4, 21. (7
10)}
We observe that the vertex with
highest number of edges is 4. Hence we select 4 as the root. The
rooted tree is drawn belov ren.
quired

5 6 2
8 7
96 3
10
The corresponding binary tree is drawn below:
Step (1) Step (2) Step (3) Step (4) Step (5)
4p
2

t
1o 03 8
10
10
This is the required binary tree.
10 3

Example (34): Draw a directed tree with 2 nodes at level 1, 5 nodes at level 2, 3 nodes at level 3.
Obtain the corresponding binary tree.
Solution:

The above tree is a directed tree with root


a, 2 nodes band cat level 1, 5 nodes b,
nodes i jand k at level 3.
c, f, g and h at level
2,

10
The responding binanary tree is
Step (11) drawn
Step ( below
a ap
Step (3)
b ap Step (4)
ap
Step (5)
dd d
oe d

This is the
e
a
required binary tree.
Representation of Algebraic
In an algebrai
assumeExpressions
raic
arguments haveexpression, by Binary Trees:
we
beern that no
Every expression evaluated. operations such *t, *, etc can be
The Central contains a
central operator performed until both of its
operator corresponds to the corresponding to the last
operator are the lett and root of the
binary tree. The leftcomputation that can be
arguments of performea
exhausted. right child of the root and right
the
respectively. This process continues until the central
expression is
Example (35): Represent the
Venn diagrams. following algebraic expression
using binary tree. Also draw the
i)x * y,(ii) (a *b)(c + d),
(iii) ((a +b)/c) +(x + y),
(v) 3-2((11-(9-4)) +(2+(3+(4+7)) (iv)(x +(y +z)) -(a x(b+©))
Solution :() Given
algebraic expression is x* y. Here * is the
required binary tree and Venn diagram are drawn below. Central operator and hence it is the root. The

Binary Tree Venn diagram


(i) Given algebraic expression is (a * b)l(c+ d). Here | is the central operator and hence it is the [Link]
required binary tree and Venn diagram are drawn below.

Venn Diagram

(ii) Given algebraic expression (a


is b) | c)+ (x + y). Here + is the central operator and hence it is the
+

free and Venn diagram are drawn below.


root. The required binary

Bihary Tree Ven Diagram


Alliance & Cn.
T
(a x
(b + c). Here
is the central operator Iheory
(iv) Given algebraic expression is (x +
(y +z))-
drawn below.
hence it is
tree and Venn diagram are
the root. The required binary

Venn Diagram
Binary Tree

(2+(3+(4+7)))hereis
is the central
(3-2(-(11-(9-4))))+
(v) Given algebraic expression is
the root.
operator and hence it is below.
The required binary tree and Venn diagram are drawn

3-2( (11-(9-4)) + (2+(3+ (4 +7)))


3-2-(11-5))(2+(3+11)) =(3-2-6)+ (2+14)
=
-5/16
Ex.40. Represent the following algebraic expressions by
binary tree.
3-(2x) + {(x -2)-3+x)} +xy.
CS/CT/CE: W-06, IT: W-09
(ii) (2x + (3-4x)) +(x - (3 x 11)

CS/CT/CE: S-13, 1T: S-06


Soln.
(i) The given algebraic expression is {3 (2x) + [(x -2)
(3+x)}+xy. Hence + is the central operator and
hence it is the root. The
required binary tree is drawn
below.

Binary Tree

(ii) The given algebraic expression is (2x (3 4x))


(x-(3 x 11).
Here +is the central operator and hence it is the root.
The required binary tree is drawn below
U)
(+)

2 3 (11)
X

Binary Tree

You might also like