breadth-first depth-first best-first
Computer Science An Overview _J. Glenn Brookshear _11th Edition
For our example in Figure 11.7, we chose a starting configuration that produces a
manageable search tree. In contrast, the search tree generated in an attempt to
solve a more complex problem could grow much larger. In a game of chess, there
are twenty possible first moves so the root node of the search tree in such a case
would have twenty children rather than the three in the case of our example.
Moreover, a game of chess can easily consist of thirty to thirty-five pairs of
moves. Even in the case of the eight-puzzle, the search tree can become quite
large if the goal is not quickly reached. As a result, developing a full search tree
can become as impractical as representing the entire state graph.
One strategy for countering this problem is to change the order in which the
search tree is constructed. Rather than building it in a breadth-first manner
(meaning that the tree is constructed layer by layer), we can pursue the more
promising paths to greater depths and consider the other options only if these
original choices turn out to be false leads. This results in a depth-first construc-
tion of the search tree, meaning that the tree is constructed by building vertical
paths rather than horizontal layers. More precisely, this approach is often called
a best-first construction in recognition of the fact that the vertical path chosen
for pursuit is the one that appears to offer the best potential.
The best-first approach is similar to the strategy that we as humans would
apply when faced with the eight-puzzle. We would rarely pursue several options
at the same time, as modeled by the breadth-first approach. Instead, we probably
would select the option that appeared most promising and follow it first. Note
that we said appeared most promising. We rarely know for sure which option is
best at a particular point. We merely follow our intuition, which may, of course,
lead us astray. Nonetheless, the use of such intuitive information seems to give
humans an advantage over the brute-force methods in which each option was
given equal attention, and it would therefore seem prudent to apply intuitive
methods in automated control systems.
o this end, we need a way of identifying which of several states appears to
be the most promising. Our approach is to use a heuristic, which in our case is
a quantitative value associated with each state that attempts to measure the “dis-
tance” from that state to the nearest goal. In a sense, our heuristic is a measure of
projected cost. Given a choice between two states, the one with the smaller
heuristic value is the one from which a goal can apparently be reached with the
least cost. This state, therefore, would represent the direction we should pursue.
A heuristic should have two characteristics. First, it should constitute a rea-
sonable estimate of the amount of work remaining in the solution if the associ-
ated state were reached. This means that it can provide meaningful information
when selecting among options—the better the estimate provided by the heuris-
tic, the better will be the decisions that are based on the information. Second, the
heuristic should be easy to compute. This means that its use has a chance of ben-
efiting the search process rather than of becoming a burden. If computing the heuristic is extremely complicated, then we might as well spend our time conducting a breadth-first search.