
File:Animated_BFS.gif · Wikimedia Commons · See Wikimedia Commons
breadth-first search
Sign in to saveAlso known as BFS, breadth first search
algorithm for searching the nodes of a graph in order by their hop count from a starting node
Key facts
- Class
- Search algorithm
- Data structure
- Graph
- Worst case performance
- O ( | V | + | E | ) {\displaystyle O(|V|+|E|)}
- Worst case space complexity
- O ( | V | ) {\displaystyle O(|V|)}
- Optimal
- Yes (always finds shortest paths)
via Wikipedia infobox
Wikidata facts
- Image
- Breadth-first-tree.svg
Show 5 more facts
- time of discovery or invention
- 1945-00-00
- Commons category
- Breadth-first search
- Stack Exchange tag
- stackoverflow.com/tags/breadth-first-search
- short name
- BFS
- described at URL
- www.javatpoint.com/ai-uninformed-search-algorithms
via Wikidata · CC0
~9 min read
Article
BFS on Maze-solving algorithm Top part of Tic-tac-toe game tree Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next depth level. Extra memory, usually a queue, is needed to keep track of the child nodes that were encountered but not yet explored.
For example, in a chess endgame, a chess engine may build the game tree from the current position by applying all possible moves and use breadth-first search to find a winning position for White. Implicit trees (such as game trees or other problem-solving trees) may be of infinite size; breadth-first search is guaranteed to find a solution node if one exists.