Medium

Breadth First Search

Breadth-first search visits vertices in order of distance from the start, using a queue. On an unweighted graph the first time you reach a vertex is a shortest path.

Costs

CategoryAlgorithm
DifficultyMedium
Time, adjacency listO(V + E)
Time, adjacency matrixO(V²)
QueueO(V)

Questions

What is Breadth First Search?

Breadth-first search visits vertices in order of distance from the start, using a queue. On an unweighted graph the first time you reach a vertex is a shortest path.

Where do I practice it?

DSA Master keeps challenges and progress on the phone. This page is the idea and the costs.