Professional Documents
Culture Documents
JITENDER KUMAR
SECTION C6803
ROLL NO A11
Part-A
Q1. ) Following is the incidence matrix M of an undirected graph G:
0 0 1 0 0 1 1 1
0 1 0 1 0 0 1 0
1 0 1 1 0 0 0 0
0 0 0 0 1 0 0 1
1 1 0 0 1 1 0 0
ANS.) Graph is
00 4 4
22 55 66 77 1 1
33
Adjacency matrix-:
10101111
01011010
10110000
01110001
11001100
10001100
11000010
10010001
Q2.) Consider the weighted graph G, and assume the nodes are
stored in an array DATA as follows:
DATA:X, Y, S, T
7
X 3 Y
1
6 2
4
S T
5
0 7 0 0
W= 3 0 0 2
6 1 0 4
0 0 5 0
7 2 5
X Y T S
Part-B
Q4.) The Web can be modeled as a directed graph. Come up with a
graph traversal algorithm. Make the algorithm non-recursive and
breadth-first.
The edges of a graph provide the connections between one node and
another. By default, an edge is assumed to be bidirectional. That is, if
there exists an edge between nodes v and u, it is assumed that one can
travel from v to u and from u to v. Graphs with bidirectional edges are
said to be undirected graphs, because there is no implicit direction in
their edges.
11 33
44
22
Incidence matrix-:
0 1 0 1 0
1 0 0 0 1
0 0 0 1 1
1 0 1 0 1
0 1 1 1 0
b) Mid-square method
i) 9614 = (61)^2
= 3721
Hence, 3721 is the location
ii) 5882 = (88)^2
= 7744
Hence, 7744 is the location
iii) 6713 = (71)^2
= 5041
Hence, 5041 is the location
iv) 4409 = (40)^2
= 1600
Hence, 1600 is the location
vi) 1825 = (82)^2
= 6724
Hence, 6724 is the location