Chapter03a Annotated PDF
Chapter03a Annotated PDF
7 2 4 1 2
5 6 3 4 5
8 3 1 6 7 8
7 2 4 1 2
5 6 3 4 5
8 3 1 6 7 8
Zerind 87
75 151
Iasi
Arad
140
92
Sibiu Fagaras
99
118
Vaslui
80
Rimnicu Vilcea
Timisoara
142
111 Pitesti 211
Lugoj 97
70 98
85 Hirsova
Mehadia 146 101 Urziceni
75 138 86
Bucharest
Dobreta 120
90
Craiova Eforie
Giurgiu
Hence the states of the robot, abstracted for this problem, are ”the
cities where the robot is/may be at”.
The corresponding operators taking one state to the other are ”driving
between cities”.
Find solution: sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest
6 1 88 6
8 84
7 3 22 7 6 25
states??
operators??
goal test??
path cost??
6 1 88 6
8 84
7 3 22 7 6 25
R R
depth = 6
State 5 4 Node
g=6
6 1 88
state
7 3 22
children
The Expand function creates new nodes, filling in the various fields and
using the Operators (or SuccessorFn) of the problem to create the
corresponding states.
Note that there are pointers (links) from Parent to Child, as well as from Child to parent, so as to be able to recover a solution once the goal is
found.
B C B C B C B C
D E F G D E F G D E F G D E F G
Arad Oradea
Rimnicu
Arad Oradea Arad Oradea Fagaras Vilcea Arad Lugoj
b =3 ,
1 Expanded
solutionin3stegsfromstartmfstate.fr
-
) 1+31-9+26=39
3
00 o 3h09
folk
NA a
Al N⑧ ,
27 Chapter 3, Sections 3.1–3.4.5 35
Örs 79
-
. _
With even small depths (d=12), both time and space are problematic (but
space is the bigger problem).
become speed
Tbylğ for
ve can
B C B C B C
D E F G D E F G D E F G
H I J K L M N O H I J K L M N O H I J K L M N O
A A A
B C B C C
D E F G D E F G E F G
H I J K L M N O I J K L M N O J K L M N O
A A
C B C C
E F G E F G F G
J K L M N O K L M N O L M N O
A A A
C C C
F G F G F G
L M N O L M N O M N O
W hal -
dayan netice
aboutseaareguiremeub-7-fffiaenl-IEasyrec.ws
-
Chapter 3, Sections 3.1–3.4.5 39
ementatron ! ! ne mel
Properties of depth-first search
Complete??
Time?? "
Space??
Optimal??
0lb .
m
)
1A
rad
B
/
Aradı
/
B.
'
Ö wnksswedoryeatedst.de de
duy; in
Chapter 3, Sections 3.1–3.4.5
which case
41
m
1¥
M = Max dertle oftree
Space?? 0lb ]
Optimal??
Notice here that you can find the big-Oh answer by considering the number
of nodes in the last level that needs to be considered.
E.g. when we know that there are 20 cities on the map of Romania, there is
no need to look beyond depth 19. Compare with the diameter of a problem.
Implementation: a d :O
↳
Nodes at depth l have no successors
da
¥
1=12
- .
_
Arad
Arad
Arad
Arad Oradea
Arad
Rimnicu
Arad Oradea Arad Oradea Fagaras Vilcea
Arad
Rimnicu
Arad Oradea Arad Oradea Fagaras Vilcea Arad Lugoj
Complete?? Yes
Time?? (d + 1)b0 + db1 + (d − 1)b2 + . . . + bd = O(bd)
Space??
Optimal??
Note: Number of visited nodes
II.
ö
, ¥!
Hatim üstüme
} d. b
'Y!ed
!
tür
dtimes
Chapter 3, Sections 3.1–3.4.5 56
Properties of iterative deepening search
Complete?? Yes
Time?? (d + 1)b0 + db1 + (d − 1)b2 + . . . + bd = O(bd)
Space?? O(bd)
Optimal??
EistePreferred method when there is a large search space and the depth of the
solution is not known.
j ;D
75 140 118
fonda
140
lsibiufmis.la?Xd
146 118
FRONT
of 1
Q o
75 140 118
75 71
Arad Oradea
75 140 118
75 71
Zerind Sibiu
①
Timisoara
118 111
Arad Oradea
paha ast : ? Arad Lugoj
to Orada
146
÷ ÷ .
500
Chapter 3, Sections 3.1–3.4.5 71
Optimality of uniform-cost search
When a path to Bucharest is found via Fagaras, and later via Pitesti, Bucharest
node is replaced to reflect the new found path. So that when it is taken from
the fringe and goal-tested, we find the right path.
Sibiu Fagaras
99
80
Rimnicu Vilcea
Pitesti 211
97
101
Bucharest
Start Goal
Mü
âna
¥ü÷ Chapter 3, Sections 3.1–3.4.5 74
Bidirectional search
Need to define predecessors
Operators may not be reversible
What if there are many goal states?
#%
Time? O(bd/2)
Space? O(bd/2)
For b=10, d = 6, BFS vs. BDS: million vs 2222 nodes .
Note that Y es∗ and No are not that different: they both do not guarantee
completeness, only differ in the strength of the assumptions (b is finite or
the max. depth is finite etc.)
B B B
A
C C C C C
{1, 2, 3, 4, 5, 6, 7, 8}
e.g., Right goes to {2, 4, 6, 8}. Solution?? 3 4
Solution??