AI engineering glossary · Data structures algorithms
What is BFS (breadth-first search)?
Breadth-first search (also called BFS): A graph traversal that visits all vertices at distance 1 from the start, then distance 2, and so on, using a queue. On graphs with equal edge costs it finds the path with the fewest edges.
Breadth-first search: an example
Finding the fewest hops between two people in a social network: expand friends, then friends of friends, until the target is reached.
Related terms
More Data structures algorithms terms
- Bubble sort
- Call stack
- Circular buffer
- Coin change problem
- Collision
- Comparison sort
- Connected components
- Consistent hashing
Where you learn it
Breadth-first search is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.