You are on page 1of 14

TREES AND

ITS
PROPERTIES
GROUP 12
INTRODUCTION
DEFINATION: A tree is a simple ,
connected , undirected graph with no
simple circuits. This means there is a
unique simple path any two of its
vertices.
Basic Terminology:
Root: A binary tree has a unique node called the root of the tree.

Left Child: The node to the left of the root is called its left child.

Right Child: The node to the right of the root is called its right child.

Parent: A node having a left child or right child or both are called the parent of the nodes.

Siblings: Two nodes having the same parent are called siblings.

Leaf: A node with no children is called a leaf. The number of leaves in a binary tree can vary
from one (minimum) to half the number of vertices (maximum) in a tree.

Descendant: A node is called descendant of another node if it is the child of the node or child
of some other descendant of that node. All the nodes in the tree are
descendants of the root. 3
For the tree as shown in fig:
•Which node is the root?
•Which nodes are leaves?
•Name the parent node of each node

•Solution: (i) The node A is the root node.


(ii) The nodes G, H, I, L, M, N, O are leaves.
(iii) Nodes Parent
B, C A
D, E B
F C
G, H D
I, J E
K F
L, M J
N, O K

4
PROPERTIES OF TREES

1. There is only one path between


each pair of vertices of a tree.
2. If a graph G there is one and
only one path between each
pair of vertices G is a tree.
3. A tree T with n vertices has n-1
edges.
4. A graph is a tree if and only if
it a minimal connected

5
ROOTED TREE

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.
m-ary Tree
an m-ary tree is a rooted tree in which each node has no
more than m children. A binary tree is the special case
where m = 2
Types of m-ary trees
A full m-ary tree is an m-ary tree where within each level
every node has either 0 or m children.

•A complete m-ary tree is an m-ary tree which is


maximally space efficient. It must be completely filled on
every level except for the last level. However, if the last
level is not complete, then all nodes of the tree must be
"as far left as possible".

•A perfect m-ary tree is a full m-ary tree in which all leaf


nodes are at the same depth. An example of a m-ary tree with m=5

7
Theorem

In an m-ary tree:
• number of nodes n
• number of leaves l
• number of internal nodes i
• n=m·i+1
• l = n − i = m · i + 1 − i = (m − 1) · i + 1
• i = l−1 m−1

8
EXAMPLE
Q}How many matches are played in a tennis tournament of 27
players?

SOLUTION

I a leaf for each player: l = 27


I an internal node for each match: m = 2
number of matches: i = (l−1) /(m−1) = (27−1)/( 2−1) = 26

9
BINARY TREES:

• If the outdegree of every


node is less than or equal to
2, in a directed tree than the
tree is called a binary tree.
A tree consisting of the
nodes (empty tree) is also a
binary tree.
DIFFERENTIATE BETWEEN GENERAL TREE AND BINARY
TREE
GENERAL TREE BINARY TREE
There is no such tree having
1. 1.There may be an empty
zero nodes or an empty binary tree.
general tree.
If some node has a child, then
2. 2.If some node has a child, then
there is no such distinction. it is distinguished as a left
child or a right child.
The trees shown in fig are the
3.
3. The trees shown in fig are distinct,
when we consider them as binary
same, when we consider them trees, because in (i)4 is the right
as general trees. child of 2 while in (ii) 4 is a left
child of 2.

11
PATH LENGTH OF A
VERTEX:
• The path length of a vertex in a rooted tree
is defined to be the number of edges in the
path from the root to the vertex.

• Find the path lengths of the nodes b, f, l, q as


shown in fig:
• Solution: The path length of node b is 1
The path length of node f is two.
The path length of node l is three
The path length of the node q is 4

12
team

13
14

You might also like