Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Student Information

Full Name : Badshah Kazmi


Id Number : 2492106

Q. 1
a.

Choice Edge Weight


1 {e,f} 1
2 {e,h} 2
3 {g,h} 2
4 {a,d} 2
5 {d,g} 3
6 {b,d} 3
7 {c,f} 3
8 {h,i} 4
Total: 20

b.
a b c

d e f

g h i

c.
To construct another minimum spanning tree for G we must add one of the edges of G not in the MST
obtained above and then delete one of the pre-existing edges in the MST since adding a new edge will
introduce a cycle. The edge we delete must be of the same weight as the edge added to keep the total
weight of the MSTs same. For our choices we can not choose the edges weighted above 4 since that will
make the total weight of the new MST higher than the current MST. Our only choices are {f, h}, {c, f }
and {b, c}, but it is easily verifiable that adding one of these edges either introduces an irremovable cycle
or deleting another of the same-weighted edge in the new edge addition leaves the tree disconnected, so
the minimum tree obtained is indeed unique.

In general, for any connected edge-weighted undirected graph, if all the edges of the graph have a distinct
weight than there exists a unique MST for G, proof is as follows:
Assumption:

Let’s assume G has two distinct MSTs, S and T .

Proof by contradiction:

Let us assume an edge with lowest weight e = P Q which is present in S but not T .

1
If we add e to T , we will have a cycle. If all other edges in T were in S . S would definitely have a
cycle which it cannot.
So the cycle in T must contain an edge f which is not in S .
So by definition of e and fact that all weights are different. W (e) < W (f ) . So if we replace f by e
we get a MST with smaller total weight which is a contradiction.
so S and T must be equal.

For graphs with indistinct edge-weights, the MST may be unique or not, we can verify this by repeating
Kruskal’s algorithm but this time adding the edges not in the existing MST first and then the rest at
each step, if we find a new edge (not in existing MST) that connects two different trees then we can claim
there are multiple MSTs for the graph. If we do not find such an edge, the MST is unique.

Q. 2
Both G and H are simple graphs since there are no multiple edges or loops present. For G = (V1 , E1 )
and H = (V2 , E2 ) to be isomorphic there must exist a one-to-one and onto function f from V1 to V2 with
the property that a and b are adjacent in G if and only if f (a) and f (b) are adjacent in H, for all a and
b in V1 .

Such a function f can readily be defined, where

f (a) = n
f (b) = q
f (c) = o
f (d) = r
f (e) = m
f (f ) = p

The conditions for isomorphism hold for f so G and H are isomorphic. This can be verified by applying
f to G and confirming that adjacency of H is preserved in the resulting graph:
d a

f
e b

c
r n

p
m q

2
Q. 3
a.
Vertices = 7
Edges = 6
Height 3

b.
Post-Order: q, s, u, v, t, r, p
In-Order: q, p, s, r, u, t, v
Pre-Order: p, q, r, s, t, u, v

c.
T is a full binary tree since each internal vertex of tree (vertex that is not a leaf) has 2 children.

d.
T is not a complete binary tree since a complete binary tree must have all of its levels completely filled,
except possibly the lowest one which is filled from the left, but in T the second level should have 4 vertices
(completely filled) to be complete, since it is not the lowest level, but it only has 2 vertices so T is not a
complete binary tree.

e.
For T to be balanced, all its leaves must be at a level h or h − 1, where h is the height of the tree, but in
T , the vertex q is a leaf but its at level 1 which is h − 2 (since h = 3) so T is not a balanced binary tree.

f.
For T to be a binary search tree, for each vertex v in T , the key of v must be larger than keys of all
vertices in its left subtree and smaller than keys of all vertices in its right subtree, but in T , r has the key
24 while u in its right subtree has a key 23 and since 23 < 24, T is not a binary search tree.

g.
Let us first consider a binary tree with height 5 which has the minimum number of nodes. Such a tree
would only have a left child (or only right) for each internal node, and so the number of nodes in such a
tree would be 6 (h + 1):

x
x
x
x
x
x

To turn this tree into a full binary tree with the addition of least possible nodes, we must add another
child to each internal node, and since there are 5 internal nodes that would mean 5 new nodes are added.
This would make the binary tree complete and thus the minimum number of nodes in a full binary tree

3
of height 5 is 5+6 = 11.

x
x x
x x
x x
x x
x x

You might also like