[prev] 73 [next]

Breadth-first Search (cont)

Time complexity of BFS: O(V+E)   (adjacency list representation, same as DFS)

BFS finds a "shortest" path

  • based on minimum # edges between src and dest.
  • stops with first-found path, if there are multiple ones

In many applications, edges are weighted and we want path

  • based on minimum sum-of-weights along path src .. dest
We discuss weighted/directed graphs later.