Next: Heuristic Search
Up: Problems and Search
Previous: Searching
Depth-First Search
- Set
to be a list of the initial nodes in the problem.
- If
is empty, fail otherwise pick the first node
from
- If the
e is a goal state, quit and return path from initial node.
- Otherwise remove
from
and add to the front of
all of
's
children. Label each child with its path from initial node. Return to 2.
Fig.
Depth First Tree Search
Note: All numbers in Fig
refer to order visited in
search.
Breadth-First Search
- Set
to be a list of the initial nodes in the problem.
- If
is empty, fail otherwise pick the first node
from
- If the
e is a goal state, quit and return path from initial node.
- Otherwise remove
from
and add to the end of
all of
's
children. Label each child with its path from initial node. Return to 2.
Fig.
Breadth First Tree Search
Note: All numbers in Fig
refer to order visited in
search.