Breadth-first search
easyEvery node at distance 1 is dequeued before any node at distance 2. Includes the single most common BFS bug: marking nodes on dequeue instead of on enqueue.
Worst
O(V + E)Space O(V)Loading the breadth-first search engine…