0
0
DSA Cprogramming~5 mins

Adjacency Matrix Representation in DSA C - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an adjacency matrix in graph representation?
An adjacency matrix is a 2D array used to represent a graph where each cell at row i and column j indicates if there is an edge from vertex i to vertex j.
Click to reveal answer
beginner
How do you represent no edge between two vertices in an adjacency matrix for an unweighted graph?
You represent no edge by storing 0 in the cell corresponding to those two vertices in the adjacency matrix.
Click to reveal answer
intermediate
In an adjacency matrix for a weighted graph, what value is typically used to represent no edge?
A special value like a very large number (e.g., INT_MAX) is used to represent no edge, depending on the implementation.
Click to reveal answer
beginner
What is the time complexity to check if an edge exists between two vertices using an adjacency matrix?
It is O(1) because you directly access the matrix cell at [i][j].
Click to reveal answer
intermediate
What is a disadvantage of using adjacency matrix for graph representation?
It uses O(V²) space, which can be inefficient for graphs with many vertices but few edges (sparse graphs).
Click to reveal answer
What does a 1 in the adjacency matrix cell [2][3] indicate in an unweighted graph?
AThere is an edge from vertex 2 to vertex 3
BThere is no edge from vertex 2 to vertex 3
CVertex 2 and 3 are the same
DThe graph is weighted
What is the size of an adjacency matrix for a graph with 5 vertices?
A4 x 4
B5 x 4
C5 x 5
DDepends on number of edges
Which operation is fastest with adjacency matrix representation?
AList all neighbors of a vertex
BRemove a vertex
CAdd a new vertex
DCheck if an edge exists between two vertices
What is the space complexity of adjacency matrix for a graph with V vertices?
AO(V²)
BO(V)
CO(E)
DO(1)
In a weighted graph adjacency matrix, what does a 0 usually mean?
ANo edge between vertices
BEdge weight zero
CEdge exists with weight 1
DGraph is unweighted
Explain how an adjacency matrix represents edges in a graph.
Think of a table where rows and columns are vertices.
You got /3 concepts.
    Describe the advantages and disadvantages of using adjacency matrix for graph representation.
    Consider speed and memory use.
    You got /3 concepts.