BWG7JK53 3
BWG7JK53 3
BWG7JK53 3
edges between nodes. Edges may be undirected or di- ators, an initial state, and a description of the goal
rected, depending on whether their corresponding state. The most important brute-force techniques are
operators are reversible or not. The task in a single- breadth-first, uniform-cost, depth-first, depth-first
agent path-finding problem is to find a path in the iterative-deepening, and bidirectional search. In the
graph from the initial node to a goal node. Figure 1 descriptions of the algorithms below, to generate a node
shows a small part of the Eight Puzzle problem-space means to create the data structure representing the
graph. state, whereas to expand a node means to generate all
Although most problem spaces correspond to the children of that node.
graphs with more than one path between a pair of
nodes, for simplicity they are often represented as
trees, where the initial state is the root of the tree. A. Breadth-First Search
The cost of this simplification is that any state that can
be reached by two different paths will be represented Breadth-first search expands nodes in order of their dis-
by duplicate nodes in the tree, increasing the size of tance from the root node, generating one level of the
the tree. The benefit of a tree is that the absence of tree at a time until a solution is found (see Fig. 2). It
cycles greatly simplifies many search algorithms. In is most easily implemented by maintaining a queue of
this survey, we will restrict our attention to trees, but nodes, initially containing just the root, and always re-
there exist graph versions of all of the algorithms we moving the node at the head of the queue, expand-
describe as well. ing it, and adding its children to the tail of the queue.
One feature that distinguishes AI search algorithms Since it never generates a node in the tree until all
from other graph-searching algorithms is the size of nodes at shallower levels have been generated,
the graphs involved. For example, the entire chess breadth-first search always finds a shortest path to a
graph is estimated to contain more than 1040 nodes. goal. Since each node can be generated in constant
Even a small problem like the Twenty-Four Puzzle time, the amount of time used by breadth-first search
contains almost 1025 nodes. As a result, the problem- is proportional to the number of nodes generated,
space graphs of AI problems are never represented which is a function of the branching factor b and the
explicitly by listing each state, but rather are implic- solution depth d. Since the number of nodes at level
itly represented by specifying an initial state and a set d is bd, the total number of nodes generated in the
of operators to generate new states from existing worst case is b b2 b3 bd, which is O(bd),
states. Furthermore, the size of an AI problem is rarely the asymptotic time complexity of breadth-first search.
expressed as the number of nodes in its problem- The main drawback of breadth-first search is its
space graph. Rather, the two parameters of a search memory requirement. Since each level of the tree
tree that determine the efficiency of various search al- must be stored in order to generate the next level,
gorithms are its branching factor and its solution depth. and the amount of memory is proportional to the
The branching factor is the average number of chil- number of nodes stored, the space complexity of
dren of a given node. For example, in the Eight Puz- breadth-first search is also O(bd). As a result, breadth-
zle the average branching factor is 3 , or about 1.732. first search is severely space-bound in practice, and
The solution depth of a problem instance is the length will exhaust the memory available on typical comput-
of a shortest path from the initial state to a goal state, ers in a matter of minutes.
or the length of a shortest sequence of operators that
solves the problem. For example, if the goal were in
the bottom row of Fig. 1, the depth of the problem
instance represented by the initial state at the root
would be three moves.