19.01.2015 Views

pdf(for print) - Computer Graphics Laboratory

pdf(for print) - Computer Graphics Laboratory

pdf(for print) - Computer Graphics Laboratory

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Depth-First Search (1/3)<br />

• Always exploring the child of the most recently<br />

expanded node<br />

• Terminal nodes being examined from left to right<br />

• If the node has no children, the procedure backs up<br />

a minimum amount be<strong>for</strong>e choosing another node to<br />

examine.<br />

1<br />

d = 1<br />

2 8 9<br />

d = 2<br />

Depth-First Search (2/3)<br />

• We stop the search when we select the goal node g.<br />

• Depth-first search can be implemented by pushing<br />

the children of a given node onto the front of the<br />

list L in step 4 of page 6<br />

• And always choosing the first node on L as the one<br />

to expand.<br />

3<br />

7<br />

10<br />

d = 3<br />

4<br />

5 6<br />

g<br />

11<br />

d = 4<br />

7<br />

8<br />

Depth-First Search (3/3)<br />

• Algorithm<br />

• Set L to be a list of the initial nodes in the problem<br />

• Let n be the first node on L. . If L is empty, fail.<br />

• If n is a goal node, stop and return it and path from the<br />

initial node to n.<br />

• Otherwise, remove n from L and add to the front of L all<br />

of n’s children, labelling each with its path from the<br />

initial node. Return to step 2.<br />

Breadth-First Search (1/2)<br />

• The tree examined from top to down, so every node<br />

at depth d is examined be<strong>for</strong>e any node at depth d<br />

+ 1. 1<br />

• We can implement breadth-first search by adding<br />

the new nodes to the end of the list L.<br />

1<br />

2 3 4<br />

d = 1<br />

d = 2<br />

5<br />

6<br />

7<br />

8<br />

d = 3<br />

9<br />

9<br />

10 11<br />

12<br />

g<br />

d = 4<br />

10<br />

Breadth-First Search (2/2)<br />

• Algorithm<br />

• Set L to be a list of the initial nodes in the problem<br />

• Let n be the first node on L. . If L is empty, fail.<br />

• If n is a goal node, stop and return it and path from the<br />

initial node to n.<br />

• Otherwise, remove n from L and add to the end of L all of<br />

n’s children, labeling each with its path from the initial<br />

node. Return to step 2.<br />

Heuristic Search (1/2)<br />

• Neither depth-first nor breadth-first search<br />

• Exploring the tree in anything resembling an<br />

optimal order.<br />

• Minimizing the cost to solve the problem<br />

1<br />

2<br />

d = 1<br />

d = 2<br />

3<br />

d = 3<br />

11<br />

4<br />

g<br />

d = 4<br />

12<br />

2

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

Saved successfully!

Ooh no, something went wrong!