Back to All Algorithms
Breadth-First Search (BFS)
Category: Tree / Graph | Time: O(n) | Space: O(w)
Visualization
Visual representation of the data structure
Enter tree data to start visualization.
About Breadth-First Search (BFS)

A graph traversal algorithm that explores the neighbor nodes first, before moving to the next level neighbors. It's often used to find the shortest path in an unweighted graph.

Code Editor
The code is for reference. Editing it won't affect the visualization.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Frequently Asked Questions
About Breadth-First Search (BFS)