IT lexicon Programming BFS (Breadth-First Search)

BFS (Breadth-First Search)

Programming På svenska → Updated: 2026-05-23

Graph traversal that visits every node at one depth before moving to the next. Implemented with a FIFO queue.

Guarantees the shortest path in an unweighted graph. Classic uses: shortest hop count between nodes (LinkedIn's "3 degrees"), web crawling, level-order tree traversal, "win in fewest moves" game AI.

Time complexity O(V+E), worst-case space O(V). Competitor: DFS (stack instead of queue, goes deep first), Dijkstra (when edges have weights).

← Back to the lexicon