Nepedia
Back to Discover
Independent Reader
🔢

Breadth-first search

math Maturity 11-13 Next article →

Imagine you are searching for a prize in a maze.

BFS-Algorithm Search Way
BFS-Algorithm Search Way

You do not run down just one path. Instead, you look at every path near you first. Then, you look at the next paths. This way of searching is called breadth-first search. It is a type of algorithm, which is a set of steps to solve a problem.

This method is very smart. It explores all nodes at the current depth first. A node is a point in a map or a tree. This search is guaranteed to find a goal if it exists. Some other searches can get lost in paths that never end.

Animated BFS
Animated BFS

Breadth-first search will not get lost.

To work, it needs extra memory. It uses a queue to keep track of nodes. A queue is a list of things to do. It works like a line at a store. The first node found is the first one checked.

MapGermanyGraph
MapGermanyGraph

Konrad Zuse invented this in 1945. Later, Edward F. Moore used it to find the shortest path out of a maze. It can even help find paths between cities on a map.

186 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (5)
File:Animated BFS.gif
Animated BFS.gif
File:BFS-Algorithm Search Way.gif
BFS-Algorithm Search Way.gif
File:Tic-tac-toe-game-tree.svg
Tic-tac-toe-game-tree.svg
File:MapGermanyGraph.svg
MapGermanyGraph.svg
File:GermanyBFS.svg
GermanyBFS.svg
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.