Graph Theory37 sections · 1633 units
Open in Course

Adjacency List - Efficiency

Memory Usage

The memory usage of an Adjacency List depends on the number of edges, not nodes. Space complexity: O(V+E)O(V + E).

Even if V=100000V = 100000, if E=200000E = 200000, you only store about 200000200000 entries total (accounting for both directions in undirected graphs). Compare this to the matrix approach which would need 101010^{10} cells. For sparse graphs where EE is much smaller than V2V^2, adjacency lists are the clear winner. This is why they are the default choice in competitive programming.