- Forgetting visited tracking: Without marking nodes visited, BFS can revisit nodes, causing infinite loops in graphs with cycles.
- Marking visited too late: Mark nodes as visited when adding to queue, not when processing. This prevents adding the same node multiple times.
- Wrong neighbor generation in grids: Check bounds before accessing grid cells.
Off-by-one errors cause index out of bounds.
- Not handling disconnected components: BFS from one source only reaches connected nodes. May need multiple BFS calls for disconnected graphs.