0
0
DSA Cprogramming~5 mins

Adjacency List vs Matrix When to Choose Which in DSA C - Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is an adjacency list in graph representation?
An adjacency list stores each vertex's neighbors in a list or array. It shows which nodes are directly connected to each vertex.
Click to reveal answer
beginner
What is an adjacency matrix in graph representation?
An adjacency matrix is a 2D array where each cell (i, j) shows if there is an edge between vertex i and vertex j, usually with 1 for edge and 0 for no edge.
Click to reveal answer
intermediate
When is it better to use an adjacency list over an adjacency matrix?
Use adjacency list when the graph is sparse (few edges). It saves space and is faster to iterate neighbors.
Click to reveal answer
intermediate
When is an adjacency matrix preferred?
Use adjacency matrix when the graph is dense (many edges) or when you need quick edge lookup between any two vertices.
Click to reveal answer
intermediate
What is the space complexity difference between adjacency list and matrix for a graph with V vertices and E edges?
Adjacency list uses O(V + E) space, while adjacency matrix uses O(V²) space regardless of edges.
Click to reveal answer
Which graph representation uses less space for a graph with very few edges?
ABoth use the same space
BAdjacency List
CAdjacency Matrix
DDepends on the number of vertices only
Which representation allows O(1) time to check if an edge exists between two vertices?
AAdjacency Matrix
BAdjacency List
CBoth take O(V) time
DNeither can do it in O(1)
For a graph with 1000 vertices and 10,000 edges, which representation is generally better?
AAdjacency Matrix
BUse edge list instead
CEither is fine
DAdjacency List
Which representation is easier to implement for dense graphs?
ABoth are equally easy
BAdjacency List
CAdjacency Matrix
DNeither is suitable
What is the main disadvantage of adjacency matrix for large sparse graphs?
AHigh space usage
BCannot represent directed edges
CComplex implementation
DSlow edge lookup
Explain when to choose adjacency list over adjacency matrix for graph representation.
Think about how many edges compared to vertices.
You got /3 concepts.
    Describe the advantages and disadvantages of adjacency matrix.
    Consider time and space trade-offs.
    You got /3 concepts.