1 solving problems by searching chapter 3. depth first search expand deepest unexpanded node the...

Post on 18-Jan-2016

226 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

Solving problems by searching

Chapter 3

Depth First Search

Expand deepest unexpanded node The root is examined first; then the left child of the

root; then the left child of this node, etc. until a leaf is found. At a leaf, backtrack to the lowest right child and repeat.

Does not have to keep all nodes on the open list, only retains the children of a single state

May get stuck in a deep search space Implementation : Fringe = LIFO queue, i.e., put successors at front

2

Depth-first Search Algorithm

3

4

Depth-first search

5

Depth-first search

6

Depth-first search

7

Depth-first search

8

Depth-first search

9

Depth-first search

10

Depth-first search

Depth-first Search

11

Complete? No: fails in infinite-depth spaces, spaces with loops

complete in finite spaces

Time? O(bm): terrible if m is much larger than d where m is maximum depth of any node,

d is depth of the least-cost solution but if solutions are dense, may be much faster

than breadth-first Space? O(bm), i.e., linear space!

where b is maximum branching factor of the search tree

Optimal? No

12

Depth-first search of 8-puzzle with a depth bound of 5

Depth Limited Search

13

Depth-limit for search is set at depth (level) l.

Nodes at depth (level) l have no successors in the search tree.

It is not optimal. It is complete if d < l. It has time complexity of O(bl). But space complexity is only O(bl).

Depth Limited Search

14

15

Iterative Deepening Search

Combines the benefits of depth-first and breadth-first search.

It is complete and optimal. It has time complexity of O(bd). But space complexity is only O(bd).

16

Iterative deepening search l =0

17

Iterative deepening search l =1

18

Iterative deepening search l =2

19

Iterative deepening search l =3

20

Iterative Deepening: Efficiency

Iterative deepening looks inefficient because so many states are expanded multiple times. In practice this is not that bad, because by far most of the nodes are at the bottom level. For a branching factor b of 2, this

might double the search time. For a branching factor b of 10, this

might add 10% to the search time.

21

Properties of iterative deepening search

Complete? Yes

Time? (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd)

Space? O(bd)

Optimal? Yes

Summary of algorithms

Example :

http://www.cs.rochester.edu/u/kautz/Mazes/search/applet.html

22

top related