Data Structure4
Data Structure4
of
Data Structure
(CSE2050)
SUBMITTED TO-:
SUBMITTED BY-:
Mam karnvirn
Philip sunny
Rd6803b34
10804895
Part-A
0 4
2 5 6 7 1
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
(i) Find indegree and outdegree of each node
Ans. ) indegree(X)-: 2
outdegree (X)-: 1
indegree(Y)-: 2
outdegree (Y)-:2
indegree(S)-: 1
outdegree (S)-: 3
indegree (T)-: 2
outdegree (T)-: 1
0 7 0 0
W= 3 0 0 2
6 1 0 4
0 0 5 0
Q3.) Find the matrix Q of shortest paths using Warshall’s algorithm for
the graph given in Q3.
7 2 5
X Y T S
Part-B
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.
1 3
4
2
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