Learn CS Visual

Breadth-First and Depth-First Search

A graph is a data structure made of nodes connected by edges. Breadth-first search visits all nodes one level at a time, closest first. Depth-first search follows one path to a dead end, then backtracks to try another path. The same graph yields a different visit order depending on the search strategy.

With breadth-first search, which node is visited 3rd?