Unvisited
Current
Visited (order)
In queue (BFS)

Controls

Time: O(n) | Space: O(h) DFS / O(n) BFS

Visit order

0 steps

Press Run to trace the algorithm one step at a time.