0% found this document useful (0 votes)
46 views28 pages

Unit-4 2019 v2

1. A tree is a connected graph with no cycles. A spanning tree of a connected graph is a subgraph that is a tree and contains all the vertices of the graph. (2) 2. A rooted tree is a directed tree with a unique root vertex with in-degree 0 and all other vertices having in-degree 1. Terms like leaf, level, ancestor, descendant, child, parent and siblings are used to describe the structure of a rooted tree. (3) 3. Binary trees and m-ary trees are special types of rooted trees where each vertex has at most two children (binary) or m children (m-ary). Complete binary/m-ary trees require each internal

Uploaded by

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

Unit-4 2019 v2

1. A tree is a connected graph with no cycles. A spanning tree of a connected graph is a subgraph that is a tree and contains all the vertices of the graph. (2) 2. A rooted tree is a directed tree with a unique root vertex with in-degree 0 and all other vertices having in-degree 1. Terms like leaf, level, ancestor, descendant, child, parent and siblings are used to describe the structure of a rooted tree. (3) 3. Binary trees and m-ary trees are special types of rooted trees where each vertex has at most two children (binary) or m children (m-ary). Complete binary/m-ary trees require each internal

Uploaded by

Sathwick Hk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Unit - 4

Trees
For animations :
 www.visualgo.net

 http://oscar.iitb.ac.in/availableanimations.do
Definitions : Let G = (V,E) be loop-free undirected
graph. The Graph G is called Tree if G is
connected and contains no cycles.

Ex:

(a) (c)
(b)

(e)
(d) Forest
Theorem 1: In a tree, there is one and only one
path between every pair of vertices.

Proof: Let T be a tree. Then T is a connected


simple graph.
 Since T is connected, there must be at least one
path between every two vertices.
 If there are two paths between a pair of vertices
of T, the union of the paths will become a cycle,
and T cannot be a tree.
 Thus between every pair of vertices in a tree
there must exist one and only one path.
Theorem 2: If in a graph G there is one and only
one path between every pair of vertices, then G is
a tree.
 Proof:

 Combined Theorem 1 and 2: A graph G is a


tree if and only if there is one and only path
between every pair of vertices in G.
Theorem: A tree with n vertices has n-1 edges.
OR
In every tree T=(V,E), |V| = |E | + 1
Proof: We prove the theorem by induction n.
 The theorem is obvious for n=1, n=2 and n=3.
 Assume that the theorem holds for all trees with
fewer than k vertices (i.e. n < k) where k is a
positive integer
 Consider a tree T with k vertices.
 In T, let e be an edge with end vertices u and v.
Since T is a tree, it has no cycles and therefore
there exists no other edges or path between u
and v.
 Therefore deletion of e from T will disconnect the
graph and T- e consists of exactly two
components, say T1 and T2.
 Since T does not contain any cycle, the
components T1 and T2 too do not contain any
cycles. Hence T1 and T2 are trees in their own
right.
 Both of these trees have less than k vertices
each, and therefore, according to the
assumption made (n<k), the theorem holds for
these trees; that is, each of T1 and T2 contains
one less edge than the number of vertices in it.
 Since the total number of vertices in T1 and T2
(taken together) is k, the total number of edges
in T1 and T2 is k - 2.

 But T1 and T2 taken together is T-e. Thus, T-e


contains k-2 edges. Consequently, T has exactly
k-1 edges.

 That’s the proof.


Theorem 3: A tree with n vertices has n-1 edges.
OR
In every tree T=(V,E), |V| = |E | + 1
proved by induction on E

Theorem 4: Any connected graph with n vertices


and n-1 edges is a tree.

 Remark: A disconnected graph with n vertices


and n-1 edges need not be a tree.

Combined theorem 3 and 4: A graph with n


vertices is a tree if and only if it is connected and
has n-1 edges.
Minimally connected graph:
 A connected graph is said to be minimally
connected if the removal of any one edge from it
disconnects the graph.

 Ex:
Theorem: A connected graph is a tree if and
only if it is minimally connected.

Proof: Suppose G is a connected graph which is


not a tree . Then G contains a cycle C.
 The removal of any edge e from this cycle will
not make the graph disconnected. Therefore G
is not minimally connected.
 Thus if a connected graph is not a tree then it is
not minimally connected.
 This is equivalent to saying that if a connected
graph is minimally connected then it is a tree
(contrapositive).
 Conversely, suppose G is a connected graph
which is not minimally connected. Then there
exists an edge e in G such that G-e is
connected.
 Therefore, e must be in some cycle in G. This
implies that G is not a tree.
 Thus, if a connected graph is not minimally
connected then it is not a tree.
 This is equivalent to saying that if a connected
graph is tree, then it is minimally connected
(contrapositive).
 This implies the proof of the theorem.
 If a tree has 2020 vertices, find the sum of the
degrees of the vertices.

No. of vertices |V|=2020

No. of edges is |E|=|V|-1


=2020-1=2019
Therefore by handshaking property,

The sum of degrees of vertices =2|E|=4038


 If a tree T has four vertices of degree 2, one
vertex of degree 3, two vertices of degree 4 and
one vertex degree 5, find the number of leaves in
T.
Let N be the number of leaves (pendant vertices) in T.

Then: total no. of vertices=N+4+1+2+1=N+8

Sum of degrees of vertices=N+24

Total No. of edges = N+7

Therefore by Hand shaking property,


N+24=2(N+7)
N=10
Spanning Trees
 Let G1=(V1, E1) be a subgraph of graph G. It is
called spanning tree if it is a tree and contains
all the vertices of G.
 In other words, a spanning tree of a connected
graph is spanning subgraph that is also a tree.
 Ex:
 If G has n vertices, spanning tree of G must
have n vertices and n-1 edges.
 The spanning trees are also called as skeleton
and scaffolding
 The edges of spanning tree are called its
branches.
 If T is a spanning tree of a graph G, then the
edges of G which are not in T are called chords
of G with respect to T.

 The set of all chords of G is the complement of T


in G. This set is called the chord-set or cotree
of T in G and is denoted as T.

 Ex:
 How many edges must be removed from a
connected graph with v vertices and e edges to
produce a spanning tree?

Ans: e-v+1

Cayley’s Theorem: States that the number of


different spanning trees in the complete graph
Kn is nn-2 .
Theorem: A graph is connected if and only if it
has a spanning tree.

Proof: Let G be a connected graph. If G has no


cycles, then G is a tree and G itself is a
spanning tree of G.

 If G has cycles, delete an edge from each cycle.


The resulting graph G’ is cycle-free, connected
and contains all vertices.

 This graph G’, is a spanning tree of G. thus G


has a spanning tree.
 Conversely, suppose graph G has a spanning
tree T.

 Since T is a tree, there exits a path between


every pair of vertices in T. Since T is a spanning
tree, T contains all vertices of G

 Therefore, there is a path between every pair of


vertices in G. Hence G is connected.

This completes the proof of the theorem.


Prove that a tree with two or more vertices
contains at least two pendant vertices.
 Consider a tree T with n vertices, where n  2.
Then it has n-1 edges. Therefore, the sum of the
degrees of the n vertices must be equal to
2(n-1).
 Thus, if d1,d2,d3,….,dn are the degrees of
vertices of T, we have
d1+d2+d3+…….+dn=2(n-1) =2n-2
i.e., 2(n-1) =  deg(v)  2 |v| = 2n
 If each of d1, d2, …,dn is  2, then their sum must
be atleast 2n. Since this is not true, at least one
of the d’s is less than 2.
 Thus, there is a d which is equal to 1. (since T is
connected, no d can be zero). Let us take this to
be d1, then
d2+d3+…..+dn = (2n - 2) -1 =2n - 3
i.e., 2(n -1) =  deg(v)  1+ 2(n-1)

 This is possible only if at least one of d2,d3,…,dn


is equal to 1. so, there is at least one more d
which is equal to 1.

 Thus, in T, there are at least two vertices with


degree 1; that is, there are at least two pendant
vertices.
For every tree T=(V,E), if |V|  2, then T has
at least two pendant vertices.
Proof: Let |V| = n  2. from theorem, WKT |E| = n-1,
so it follows that 2(n -1) = 2|E| = vV deg(v).
 Since T is connected, we have deg(v)  1 for all
vV.
 If there are k pendant vertices in T, then each of
the other n-k vertices has degree at least 2 and
2(n -1) = 2|E| = vV deg(v)  k +2(n-k).
From this we see that,
[2(n-1)  k+2(n-k)]  [(2n - 2)  (k + 2n - 2k) ]
 [- 2  -k ]  [k  2]
And the result is consequently established.
Rooted trees
 Let D be a directed graph and G be its
underlying graph. We say that D is a directed
tree whenever G is a tree.

 Thus, a directed tree is a directed graph whose


underlying graph is a tree.

 A directed tree T is called a rooted tree if


(i) T contains a unique vertex, called the root,
whose in-degree is equal to 0 and
(ii) The in-degree of all other vertices of T are
equal to 1.
Ex:
 Leaf: In a rooted tree, a vertex v with the out
degree zero is called a leaf (or terminal vertex).
 All other nodes are called branch nodes (or
internal vertices)
 Level: a vertex v is said to be at the kth level or
has level number k if the path from r to v is of
length k.
 Ex:
 Ancestors and Descendants: If v1 and v2 are
two vertices such that v1 has a lower level
number than v2 and there is a path from v1 to v2,
then we say v1 is an ancestor of v2, or that v2 is a
descendant of v1.
 Child and parent: If vertex v1 has a lower level
number than v2 and there is an edge (directed
edge) from v1 to v2 then v1 is called parent of v2
or v2 is called child of v1.
 Siblings: Two vertices with a common parent
are referred to as siblings.
 M-ary tree: A rooted tree T is called an m-ary
tree if every vertex of T is of out-degree  m; that
is if every vertex of T has at most m children.
 Complete m-ary tree: A rooted tree T is called a
complete m-ary tree if every internal vertex of T
is of out-degree m; that is if every internal vertex
of T has exactly m children.
 Binary tree: An m-ary tree for which m=2 is
called a binary tree.
In other words, a rooted tree T is called a
binary tree if every vertex of T is of out-degree
<=2; that is every vertex has at most two
children.
 Also called binary rooted tree

 Complete binary tree: A complete m-ary tree


for which m=2.
In other words, every internal vertex has
exactly two children.
 Balanced tree: If T is a rooted tree and h is the
largest level number achieved by a leaf of T ,
then T is said have height h.
Root node
Interior nodes Height
Leaf nodes

 A rooted tree of height h is said to be balanced


if the level number of every leaf is h or h-1.
 Full binary tree: let T be a complete binary tree
of height h. then T is called a full binary tree if all
the leaves in T are at level h.
 Let T be a complete m-ary tree of order n
with p leaves and q internal vertices.
We have
 n = mq + 1 = mp - 1 / m – 1
 p = (m - 1)q+1 = (m - 1) n + 1 / m
 q=n–1/m=p–1/m–1

For Complete binary tree ( m=2)


 n = 2q + 1 = 2p - 1
 p = q + 1 = 1/2(n+1)
 q = 1/2(n-1) = p - 1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy