Adjacency List — DSA Technical Interview Questions & Answers
Adjacency List
Adjacency List
- Adjacency List is a DSA topic. In plain words you use it for a short Adjacency List example in a short dry-run on paper. Don’t start with a slogan — start with that picture.
- Smallest example: the smallest Adjacency List example you can type. Type it, run it, and say what you see. If you can do that from memory, you know Adjacency List.
- From the example next to this theory: Adjacency List — graphs are often stored as adjacency lists: vertex → list of (neighbor, weight).
- Trap: only saying “Adjacency List” with no example. Fix that before you talk about advanced DSA.
- Viva: what is Adjacency List? Then show the smallest Adjacency List example you can type. Then name the trap.
Technical Interview Tip: What is Adjacency List? Show this: the smallest Adjacency List example you can type. Trap: only saying “Adjacency List” with no example.
Code Examples for Adjacency List
Adjacency List — working example
# adjacency list
graph = {
"A": [("B", 2), ("C", 5)],
"B": [("A", 2), ("C", 1)],
"C": [("A", 5), ("B", 1)],
}
for u, edges in graph.items():
print(u, "->", edges)Adjacency List — graphs are often stored as adjacency lists: vertex → list of (neighbor, weight).
How to Explain Adjacency List to an Interviewer
What is Adjacency List?
Used for a short Adjacency List example a short dry-run on paper Not just the heading
Give one small example of Adjacency List.
the smallest Adjacency List example you can type Adjacency List — graphs are often stored as adjacency lists: vertex → list of (neighbor, weight)
What mistake do beginners make with Adjacency List?
only saying “Adjacency List” with no example Show the fix
Where do you use Adjacency List?
a short dry-run on paper a short Adjacency List example