Medium

Adjacency List

Each vertex stores the vertices it connects to. Sparse graphs stay small. Checking one arbitrary pair means scanning that vertex’s list.

Costs

CategoryData Structure
DifficultyMedium
MemoryO(V + E)
List the neighbors of vO(degree of v)
Check one edge, unsorted listO(degree of v)

Questions

What is Adjacency List?

Each vertex stores the vertices it connects to. Sparse graphs stay small. Checking one arbitrary pair means scanning that vertex’s list.

Where do I practice it?

DSA Master keeps challenges and progress on the phone. This page is the idea and the costs.