(a) Use adjacency list, and (b) adjacency matrix to represent the graph Continue
ID: 3851040 • Letter: #
Question
Explanation / Answer
Answer For Question 6.
Graph is a collection of nodes or vertices (V) and edges(E) between them. We can traverse these nodes using the edges. These edges might be weighted or non-weighted. Now for the figure 6 it is a directed graph and the adjacency matrix for the graph should be 7*7 matrix .
adjMaxtrix[i][j] = 1 when there is edge between Vertex i and Vertex j, else 0.
So,
Adjacency List
Adjacency List is the Array[] of Linked List, where array size is same as number of Vertices in the graph. Every Vertex has a Linked List.
For the figure 6 the adjacency list is ,
a ------> b------>c------>d------>e
b------>c------>e
c------>f------>g
d------>e
e------>d
f------>e------>g
g------>null.,
a b c d e f g a 0 1 0 1 1 0 0 b 0 0 1 0 1 0 0 c 0 0 0 0 0 1 1 d 0 0 0 0 1 0 0 e 0 0 0 1 0 0 0 f 0 0 0 0 1 0 1 g 0 0 0 0 0 0 0Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.