Breadth-First Search and Breadth-First Traveral

Breath-first search is a method for walking through a tree or graph where you "fan out" as much as…

Breadth-first search (BFS) is a method for exploring a tree or graph. In a BFS, you first explore all the nodes one step away, then all the nodes two steps away, etc.

Here's how a BFS would traverse this tree, starting with the root:

Then we'd move on to all those nodes' children (all the nodes that're two steps away from our starting node):

Then we'd move on to all those nodes' children (all the nodes that're two steps away from our starting node):

And so on:

Until we reach the end.

Breadth-first search is often compared with depth-first search.

Advantages:

Disadvantages:

Date: 2020-01-30 Thu 21:46

Author: Jack Liu

Created: 2020-02-08 Sat 21:26

Validate