Professional Documents
Culture Documents
Lecture 003 - 004
Lecture 003 - 004
Problem Solving as
Searching – Informed
Search
Searching Strategies
In Today’s
Learning
Lecture
Outcomes
Uninformed Strategies
Search /Types
3
4
Examples
12
Examples
13
8 puzzles
Example http://www.permadi.com/java/puzzle8/
14
8 Tile
Puzzle
17
Romania
19
Road Distances in km
Romania
20
Examples of Search Agents
States: In City where City E { Arad, Zerind,
Bucharest,... }
Search tree:
Root: initial state
Branches: actions
Nodes: results from actions. A node has: parent,
children, depth, path cost, associated state
Expand: A function that given a node, creates all
children nodes
22
“When solving problems, dig at the roots instead of just
hacking at the leaves”
Anthony J. D'Angelo
The College Blue Book
Search and
Trees...
23
Search and Trees...
24
Search
and Trees...
25
Search and
Trees...
26
Strategies Evaluated According to:
Searching the
Search Space
29
Uninformed
search
30
Informed
search
31
Implementation:
Fringe = First In First Out (FIFO) queue, i.e., put
successors at back/end of queue
Breadth First
Search
32
Expand:
fringe = [B,C]
Is B a goal state?
Breadth First
Search
33
Expand:
fringe=[C,D,E]
Search
34
Expand:
fringe=[D,E,F,G]
Is D a goal state?
Breadth First
Search
35
Implementation:
fringe = Last In First Out (LIFO) queue, i.e., put
successors at front
DFS
39
Depth First Search
queue=[B,C]
Is B a goal state?
DFS
40
Depth First Search
queue=[D,E,C]
Is D = goal state?
DFS
41
Depth First Search
queue=[H,I,E,C]
queue=[I,E,C]
Is I = goal state?
DFS
43
Depth First Search
queue=[I,E,C]
Is I = goal state?
DFS
44
Depth First Search
queue=[E,C]
Is E = goal state?
DFS
45
Depth First Search
queue=[J,K,C]
Is J = goal state?
DFS
46
Depth First Search
queue=[K,C]
Is K = goal state?
DFS
47
Depth First Search
queue=[C]
Is C = goal state?
DFS
48
Depth First Search
queue=[F,G]
Is F = goal state?
DFS
49
Depth First Search
queue=[L,M,G]
Is L = goal state?
DFS
50
Depth First Search
queue=[M,G]
Is M = goal state?
DFS
51
DFS
52 Properties d=0
= 1 + b + b2+ ......... + bd
= O (bd)
d=0
Exponential time
Linear space
DFS
54
Comparison -- BFS - DFS
Same worst-case time Complexity, but
In the worst-case BFS is always better than DFS
Sometime, on the average DFS is better if:
Iterative
Deepening
62
Bidirectional Search
Idea
63
Bi-Directional
Search
64
65
THANKS!
Any questions?
You can find me at
Facebook/babaryaqoob92
Twitter/byaqoobkhan
66
WEEK 3 – 4