06.03.2013 Views

Artificial Intelligence and Soft Computing: Behavioral ... - Arteimi.info

Artificial Intelligence and Soft Computing: Behavioral ... - Arteimi.info

Artificial Intelligence and Soft Computing: Behavioral ... - Arteimi.info

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

We will now present two typical algorithms for generating the state<br />

space for search. These are depth first search <strong>and</strong> breadth first search.<br />

4.2.1 Breadth First Search<br />

The breadth first search algorithm visits the nodes of the tree along its<br />

breadth, starting from the level with depth 0 to the maximum depth. It can be<br />

easily realized with a queue. For instance, consider the tree, given in fig. 4.1.<br />

Here, the nodes in the tree are traversed following their ascending ordered<br />

labels.<br />

2<br />

Fig. 4.1: The order of traversal in a tree of depth 3 by<br />

breadth first manner.<br />

depth<br />

The algorithm for traversal in a tree by depth first manner can be<br />

presented with a queue as follows:<br />

Procedure Breadth-first-search<br />

Begin<br />

i) Place the starting node in a queue;<br />

ii) Repeat<br />

Delete queue to get the front element;<br />

If the front element of the queue = goal,<br />

return success <strong>and</strong> stop;<br />

1<br />

3 4<br />

5 6 7 8<br />

9<br />

10 11 12<br />

0<br />

1<br />

2<br />

3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!