Questions: Graph Representations: Adjacency List vs. Adjacency Matrix

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

You are implementing BFS on a social network graph with 1 million users (V = 10⁶) and 10 million friendships (E = 10⁷). Which representation gives better BFS performance, and why?

AAdjacency matrix — O(1) edge lookup makes the traversal faster at each step
BAdjacency list — O(V + E) traversal avoids scanning empty matrix rows for sparse graphs
CEither is equivalent — BFS visits every edge once regardless of representation
DAdjacency matrix — it uses less memory since it is stored as a fixed-size array
Question 2 Multiple Choice

What is the time complexity of checking whether a directed edge from vertex u to vertex v exists in an adjacency list representation?

AO(1) — array indexing gives direct access to u's neighbor list
BO(V) — you must scan all vertices to find v
CO(degree(u)) — you must scan u's neighbor list to find v
DO(E) — edge lookup requires scanning all edges in the worst case
Question 3 True / False

In an undirected graph stored as an adjacency list, each edge (u, v) is represented twice — once in u's list and once in v's list — so the total storage for edges is 2E entries.

TTrue
FFalse
Question 4 True / False

An adjacency matrix usually uses less memory than an adjacency list because it avoids the pointer overhead of linked lists.

TTrue
FFalse
Question 5 Short Answer

Why does the choice between adjacency list and adjacency matrix affect the time complexity of BFS and DFS, not just memory usage?

Think about your answer, then reveal below.