Intermediate~7 min · +40 XP
BFS Visit Order
Practices: Breadth-First Search
Problem
Undirected graph, edges: 0–1, 0–2, 1–3, 2–3, 3–4. BFS starts at node 0; neighbors are explored in ascending numeric order.
What is the complete visit order? (Format: comma-separated, like 0,1,2)
Examples
in: graph 0–1, 1–2, BFS from 0
out: 0,1,2
Ring order: 0, then its neighbor 1, then 1's unvisited neighbor 2.
Constraints & conventions
- Mark nodes visited when enqueued; process queue in FIFO order.
Your answer
Solve the challenge to unlock the full approach and complexity analysis.