Recursion

Graph BFS

Lesson

Just like with Tree BFS, we can get Graph BFS code by simply taking the preorder Iterative Tree DFS code, and swapping out the stack with a queue. And now that we're on a Graph, we need to keep track of the nodes we've visited so we don't enter an infinite cycle.

Mark as Completed:
Submits:
test
Test your code to get an output here!