Skip to content

Breadth-first search

Breadth-first search (BFS) search inside a graph by first prioritising all the children nodes before moving to the next one.

Animated example of a breadth-first-search

Complexity

Time complexity

  • Worst-case: O(|V|+|E|)
  • Best-case: Ω(1)

Resources