In breadth-first search the frontier is implemented as a FIFO (first-in, first-out) queue. Thus, the path that is selected from the frontier is the one that was added earliest.

This approach implies that the paths from the start node are generated in order of the number of arcs in the path. One of the paths with the fewest arcs is selected at each iteration.

###### Example 3.7.

Consider the tree-shaped graph in Figure 3.5. Suppose the start node is the node at the top, and the children of a node are added in a left-to-right order. In breadth-first search, the order in which the paths are expanded does not depend on the location of the goal. The nodes at the end of the first sixteen paths expanded are numbered in order of expansion in the figure. The shaded nodes are the nodes at the ends of the paths of the frontier after the first sixteen iterations.

###### Example 3.8.

Consider breadth-first search from $o103$ in the graph given in Figure 3.2. The only goal node is $r123$. Initially, the frontier is $[\left]$. This is extended by $o103$’s neighbors, making the frontier $[\left$, $\left$, $\left]$. These are the nodes one arc away from $o013$. The next three paths chosen are $\left$, $\left$, and $\left$, at which stage the frontier contains

 $\displaystyle{[\left,\left% ,\left,}$ $\displaystyle\ \ \ \ {\left,\left].}$

These are the paths containing two arcs starting at $o103$. These five paths are the next paths on the frontier chosen, at which stage the frontier contains the paths of three arcs away from $o103$, namely,

 $\displaystyle{[\left,\left,\left,}$ $\displaystyle\ \ \ \ {\left,\left].}$

Note how in breadth-first search each path on the frontier has either the same number of arcs or one more arc than the next element of the frontier that will be selected.

Suppose the branching factor of the search is $b$. If the next path to be selected on the frontier contains $n$ arcs, there are at least $b^{n-1}$ elements of the frontier. All of these paths contain $n$ or $n+1$ arcs. Thus, both space and time complexities are exponential in the number of arcs of the path to a goal with the fewest arcs. This method is guaranteed, however, to find a solution if one exists and will find a solution with the fewest arcs.