← Whiteboard questions

Pattern

Graphs

A graph holds things and the links between them. Walk it with depth-first or breadth-first search, and keep a record of what you have seen so you never loop. The usual cost is O(V + E), where V counts the things and E counts the links.

Graphs interview questions and solutions