28. Adjacency matrix vs adjacency list: which should you use?
EasyGraph algorithms
Technical
Show model answer
An adjacency matrix uses O(V²) space and answers "is there an edge u→v?" in O(1); it suits dense graphs. An adjacency list uses O(V + E) space and iterates neighbours efficiently; it suits sparse graphs, which most real graphs are. BFS and DFS cost O(V + E) with lists but O(V²) with a matrix.