Developer

This experience deserves a bigger screen

The DSA Visualizer is designed for deep focus,
side-by-side code, and real-time execution insight.

On small screens, that level of clarity can't be preserved.

Open on a tablet (landscape) or desktop for the intended experience.

Desktop experience preview

Breadth First Search (BFS)Step-by-Step Visualization

BFS explores neighbor nodes first, before moving to the next level neighbors. It is optimal for finding the shortest path in an unweighted graph.

Problem Statement

Implement BFS traversal for a graph given an adjacency list and a starting node.

Approach

Use a Queue. Enqueue the starting node and mark it as visited. While the queue is not empty, dequeue a node, process it, and enqueue all unvisited neighbors, marking them visited.

Time & Space Complexity

Time complexity is O(V + E) where V is vertices and E is edges. Space complexity is O(V) for the queue and visited array.

Interactive Visualization

Loading Interactive Visualizer...

Click "Play" or use arrow keys to step through the execution.