Algorithms

Adjacency list

A way to store a graph with a list of neighbors for each vertex. It only stores edges that exist: it takes O(n + m).

Example

If 1 is joined to 2, 3 and 5, its list is [2, 3, 5]. With 1 million users and 200 friends each, about 200 million entries instead of 1 trillion.

Test yourself: Adjacency list

Graphs

What does an adjacency list store?

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.