You are on page 1of 3

Problem Set 1

Due: Monday, Sep 20, 2021, 5:10pm


Princeton Ferro (pcf252@nyu.edu)
1) Show the order of nodes visited using Breadth First Search (BFS), and
the final path selected. Is this optimal? Why or why not?
S

S -> A
S -> C

S -> A -> D
S -> C -> B
S -> C -> E

S -> A -> D -> F


S -> A -> D -> G
S -> A -> D -> H
The solution found is SADG, which is not optimal, because we can take a shorter
path (SCA) from S to A. BFS does not find the optimal path because the edge
weights are not all the same.
2) Show the order of nodes visited using Iterative Deepening (initial depth
of 2, increasing depth by 1), and the final path selected. Is this optimal?
Why or why not?
max_depth = 1:

S -> A x
S -> C x

max_depth = 2:

S -> A

S -> A -> C x
S -> A -> D x

S -> C

S -> C -> A x
S -> C -> B x
S -> C -> E x

max_depth = 3:

1
S -> A

S -> A -> C

S -> A -> C -> B x


S -> A -> C -> E x

S -> A -> D

S -> A -> D -> F x


S -> A -> D -> G
S -> A -> D -> H
The solution found is SADG, which is not optimal, because we can take a shorter
path (SCA) from S to A. Again, we do not find the optimal path because edge
weights are not the same.
3) Using the above h-function, show the order of nodes visited using A*, and
the final path selected. Is this optimal? Why or why not?
SA = 12 + 9 = 21
SC = 6 + 16 = 22

(expand smallest SA, add edges from A)

SAC = 12 + 5 + 16 = 33
SAD = 12 + 6 + 2 = 20
SC = 6 + 16 = 22

(expand smallest SAD, add edges from D)

SAC = 12 + 5 + 16 = 33
SADF = 12 + 6 + 2 + 5 = 25
SADG = 12 + 6 + 3 + 0 = 21
SADH = 12 + 6 + 9 + 12 = 39
SC = 6 + 16 = 22

(expand smallest SC, add edges from C (SADG is a potential solution that can't
be expanded further))
SAC = 12 + 5 + 16 = 33
SADF = 12 + 6 + 2 + 5 = 25
SADG = 12 + 6 + 3 + 0 = 21 (potential solution)
SADH = 12 + 6 + 9 + 12 = 39
SCA = 6 + 5 + 9 = 20
SCB = 6 + 8 + 24 = 38
SCE = 6 + 11 + 27 = 44

2
(expand smallest SCA, add edges from A (we don't expand edges that loop back
onto the path))

SAC = 12 + 5 + 16 = 33
SADF = 12 + 6 + 2 + 5 = 25
SADG = 12 + 6 + 3 + 0 = 21 (potential solution)
SADH = 12 + 6 + 9 + 12 = 39
SCAD = 6 + 5 + 6 + 2 = 19
SCB = 6 + 8 + 24 = 38
SCE = 6 + 11 + 27 = 44

(expand smallest SCAD, add edges from D)

SAC = 12 + 5 + 16 = 33
SADF = 12 + 6 + 2 + 5 = 25
SADG = 12 + 6 + 3 + 0 = 21 (potential solution)
SADH = 12 + 6 + 9 + 12 = 39
SCADF = 6 + 5 + 6 + 2 = 19
SCADG = 6 + 5 + 6 + 3 = 20 (potential solution)
SCADH = 6 + 5 + 6 + 9 = 26
SCB = 6 + 8 + 24 = 38
SCE = 6 + 11 + 27 = 44
The solution found is SCADG, which is the optimal solution because it is the
shortest path from the start (S) to the goal (G). A* found the solution because
it used a heuristic that did not overestimate the path cost. Furthermore, A*
explored all possible (non-looping) paths from the start to the goal.

You might also like