Recall & Review
beginner
What is an adjacency list in graph representation?
An adjacency list is a way to represent a graph where each node stores a list of its neighboring nodes. It saves space by only storing edges that exist.
Click to reveal answer
beginner
How does an adjacency list differ from an adjacency matrix?
An adjacency list stores neighbors for each node in lists, using less space for sparse graphs. An adjacency matrix uses a 2D array to store edge presence, using more space.
Click to reveal answer
intermediate
In C, what data structure is commonly used to implement an adjacency list?
A common approach is to use an array of pointers, where each pointer points to a linked list of neighbors for that vertex.
Click to reveal answer
beginner
Why is adjacency list preferred for sparse graphs?
Because it only stores existing edges, it uses less memory and is faster to iterate over neighbors compared to adjacency matrix which stores all possible edges.
Click to reveal answer
intermediate
What is the time complexity to find all neighbors of a vertex using adjacency list?
It is O(k), where k is the number of neighbors of that vertex, since we directly access the list of neighbors.
Click to reveal answer
What does each element in an adjacency list represent?
✗ Incorrect
Each element in an adjacency list stores a vertex and a list of its neighboring vertices.
Which data structure is commonly used to store neighbors in C adjacency lists?
✗ Incorrect
Linked lists are used to store neighbors dynamically for each vertex.
What is the main advantage of adjacency lists over adjacency matrices?
✗ Incorrect
Adjacency lists use less memory when the graph has fewer edges.
How do you add an edge from vertex u to vertex v in an adjacency list?
✗ Incorrect
In adjacency lists, adding an edge means adding the destination vertex to the source vertex's neighbor list.
What is the space complexity of adjacency list for a graph with V vertices and E edges?
✗ Incorrect
Adjacency list stores vertices and edges separately, so space is proportional to vertices plus edges.
Explain how an adjacency list represents a graph and why it is efficient for sparse graphs.
Think about how you would list friends for each person instead of a big table.
You got /3 concepts.
Describe how you would implement an adjacency list in C using arrays and linked lists.
Imagine each vertex has a pointer to a chain of neighbors.
You got /3 concepts.