Understanding Graph Data Structures: Adjacency List vs Matrix
A beginner's quiz on the differences between adjacency lists and adjacency matrices in graph data structures.
Questions in this quiz
15 questions on Understanding Graph Data Structures: Adjacency List vs Matrix. Work through them here, then start the quiz to answer them and see your score.
1.What is an adjacency list in graph data structures?
- AA list of all possible paths in a graph
- BA matrix representing node connections
- CA list of all nodes with their connected nodes
- DA tree structure representing graph nodes
2.What is an adjacency matrix?
- AA matrix that shows all possible paths in a graph
- BA 2D array where each cell indicates if a pair of nodes is connected
- CA tree structure representing graph nodes
- DA list of nodes with their degrees
3.Which data structure is more space-efficient for sparse graphs?
- AHash table
- BAdjacency list
- CBinary tree
- DAdjacency matrix
4.In an adjacency matrix, what does a cell value of 1 typically represent?
- AA self-loop
- BThe weight of the edge
- CA connection or edge between nodes
- DNo connection between nodes
5.Which representation is generally faster for checking if two nodes are directly connected?
- AAdjacency matrix
- BNeither, use a different structure
- CBoth are equally fast
- DAdjacency list
6.Which graph representation is typically better for dense graphs?
- AIncidence list
- BEdge list
- CAdjacency matrix
- DAdjacency list
7.How is an edge represented in an adjacency list?
- AAs a node in a tree
- BAs a row in a matrix
- CAs a pair of nodes in a list
- DAs a column in a matrix
8.What is a disadvantage of using an adjacency matrix?
- AIt is difficult to implement
- BIt cannot represent weighted graphs
- CIt uses more space for sparse graphs
- DIt is slower for dense graphs
9.Which graph representation allows easier iteration over all edges?
- AAdjacency matrix
- BBoth are equally easy
- CNeither, use a different structure
- DAdjacency list
10.In an undirected graph, how is an edge between two nodes represented in an adjacency matrix?
- AAs a 0 in two symmetric cells
- BAs a 0 in one cell
- CAs a 1 in one cell
- DAs a 1 in two symmetric cells
11.Which graph representation is more suitable for algorithms that frequently check for the presence of specific edges?
- AAdjacency matrix
- BAdjacency list
- CEdge list
- DIncidence list
12.What is a common use case for adjacency lists?
- AStoring dense graphs
- BStoring graphs with weighted edges
- CStoring graphs with self-loops
- DStoring sparse graphs
13.How can you represent weighted edges in an adjacency list?
- ABy storing weights in a separate array
- BBy using a matrix instead
- CBy including weights in the node list
- DWeights cannot be represented
14.What is a potential drawback of using adjacency lists?
- AThey are inefficient for dense graphs
- BThey cannot represent directed graphs
- CThey use too much memory for sparse graphs
- DThey are slower for edge presence checks
15.Which graph representation would you choose for a graph with frequent updates to edges?
- AAdjacency matrix
- BAdjacency list
- CIncidence matrix
- DEdge list