Graphs

Concept shape

Practice pattern
Definition

Breadth-first search explores nodes by distance from the start using a queue.

Step 1 / 5
Concept shape
Current lesson

BFS Concept Lab

Graphs Practice pattern

BFS Concept

Welcome to the BFS Concept concept lab. Breadth-first search explores nodes by distance from the start using a queue. The must know points are: Queue controls level order. Finds shortest path in unweighted graphs. Mark nodes when enqueueing. The common operations are: enqueue, dequeue, visit neighbors. The complexity shape is O(V + E). Watch out for these pitfalls: Marking visited too late. Using DFS when shortest unweighted path is needed. Related algorithms include BFS, Level Order Traversal.

Concept details

Breadth-first search explores nodes by distance from the start using a queue.

Must know

  • Queue controls level order.
  • Finds shortest path in unweighted graphs.
  • Mark nodes when enqueueing.
1.0x