05 Uninformed Search Algorithms
05 Uninformed Search Algorithms
Spring Semester
Academic Year 2024/2025
Table of Contents
1. Objectives
3. References
“In which we see how an agent can look ahead to find a sequence of
actions that will eventually achieve its goal.”
• Breadth-First Search
• Uniform-Cost Search
• Depth-First Search
Consider the state space graph shown below. Assuming that S is the
initial state and G is the goal state. What is the solution path using
the breadth-first search algorithm?
a G
c
b
e
d f
S h
r
p q
Hint: always expand the shallowest node in the frontier first and use
the alphabetical order as a tie-breaker.
Uninformed Search Algorithms I. Abu Hashish 10
Breadth-First Search
a G
c
b
e
d f
S h
r
p q
S S
a G
c
b
e
d f
S h
r
p q
S S
S-d
d e p S-e
S-p
a G
c
b
e
d f
S h
r
p q
S S
S-d
d e p
S-e
S-p
b c e
S-d-b
S-d-c
S-d-e
a G
c
b
e
d f
S h
r
p q
S S
S-d
d e p
S-e
S-p
b c e h r
S-d-b
S-d-c
S-d-e
S-e-h
S-e-r
a G
c
b
e
d f
S h
r
p q
S S
S-d
d e p
S-e
S-p
b c e h r q
S-d-b
S-d-c
S-d-e
S-e-h
S-e-r
S-p-q
a G
c
b
e
d f
S h
r
p q
S S S-d-b-a
S-d
d e p
S-e
S-p
b c e h r q
S-d-b
a
S-d-c
S-d-e
S-e-h
S-e-r
S-p-q
a G
c
b
e
d f
S h
r
p q
S S S-d-b-a
S-d S-d-c-a
d e p
S-e
S-p
b c e h r q
S-d-b
a a
S-d-c
S-d-e
S-e-h
S-e-r
S-p-q
a G
c
b
e
d f
S h
r
p q
S S S-d-b-a
S-d S-d-c-a
d e p
S-e S-d-e-h
S-p S-d-e-r
b c e h r q
S-d-b
a a h r
S-d-c
S-d-e
S-e-h
S-e-r
S-p-q
a G
c
b
e
d f
S h
r
p q
S S S-d-b-a
S-d S-d-c-a
d e p
S-e S-d-e-h
S-p S-d-e-r
b c e h r q
S-d-b S-e-h-p
a a h r p q
S-d-c S-e-h-q
S-d-e
S-e-h
S-e-r
S-p-q
a G
c
b
e
d f
S h
r
p q
S S S-d-b-a
S-d S-d-c-a
d e p
S-e S-d-e-h
S-p S-d-e-r
b c e h r q
S-d-b S-e-h-p
a a h r p q f
S-d-c S-e-h-q
S-d-e S-e-r-f
S-e-h
S-e-r
S-p-q
a G
c
b
e
d f
S h
r
p q
S S S-d-b-a
S-d S-d-c-a
d e p
S-e S-d-e-h
S-p S-d-e-r
b c e h r q
S-d-b S-e-h-p
a a h r p q f
S-d-c S-e-h-q
. . .
. . . S-d-e S-e-r-f
. . .
. . . S-e-h .
.
. . .
. . . S-e-r .
.
. . .
S-p-q .
.
.
a G
c
b
e
d f
S h
r
p q
S S S-d-b-a
S-d S-d-c-a
d e p
S-e S-d-e-h
S-p S-d-e-r
b c e h r q
S-d-b S-e-h-p
a a h r p q f
S-d-c S-e-h-q
.
. . .
S-d-e .
. . . c G .
. . .
S-e-h
. . . S-e-r-f
. . .
S-e-r
. . . S-e-r-f-c
. . .
S-p-q
S-e-r-f-G
1 node
S
b
b nodes
b2 nodes
m d
bd nodes
G
bm nodes
Where d is the depth, i.e., the number of actions in an optimal path, m is the
maximum number of actions in any path, while b is the branching factor, i.e.,
the number of successors of a node that need to be considered.
Uninformed Search Algorithms I. Abu Hashish 23
Breadth-First Search Performance Evaluation
Is it complete?
• Yes.
• Yes, assuming all actions have the same cost – always finds a
solution with a minimal number of actions, because when it is
generating nodes at depth d, it has already generated all the
nodes at depth d − 1.
Assuming that Sibiu is the initial state, and Bucharest is the goal
state, what is the solution path using uniform-cost algorithm?
Consider the state space graph shown below. Assumin that S is the
initial state and G is the goal state. What is the solution path using
the uniform-cost search algorithm?
2
a 2 3
G
c
b 2
8
1
2 e
d f
3 9 8
2
1
S h
4
1 4 r
p 15 q
Hint: always expand the cheapest nodes in the frontier first and use
the alphabetical order as a tie-breaker.
2
a 2 3
G
c
b 2
8
1
2 e
d f
3 9 8
2
1
S h
4
1 4 r
p 15 q
S
S
2
a 2 3
G
c
b 2
8
1
2 e
d f
3 9 8
2
1
S h
4
1 4 r
p 15 q
S
S
3 9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a h r
8 S-d-c S-e-r
f
S-d-e
11 10
S-d-b-a
c G
Is it complete?
• Yes – the first solution it finds will have a cost that is at least as
low as the cost of any other node in the frontier.
a G
c
b
e
d f
S h
r
p q
Hint: always expand the deepest node in the frontier first and use
the alphabetical order as a tie-breaker.
Uninformed Search Algorithms I. Abu Hashish 39
Depth-First Search
a G
c
b
e
d f
S h
r
p q
S
S
a G
c
b
e
d f
S h
r
p q
S
S
S-d
d e p
S-e
S-p
a G
c
b
e
d f
S h
r
p q
S
S
S-d
d e p
S-e
S-p
b c e
S-d-b
S-d-c
S-d-e
a G
c
b
e
d f
S h
r
p q
S
S
S-d
d e p
S-e
S-p
b c e
S-d-b
a S-d-c
S-d-e
S-d-b-a
a G
c
b
e
d f
S h
r
p q
S
S
S-d
d e p
S-e
S-p
b c e
S-d-b
a a S-d-c
S-d-e
S-d-b-a
S-d-c-a
a G
c
b
e
d f
S h
r
p q
S
S S-d-e-h
S-d S-d-e-r
d e p
S-e
S-p
b c e
S-d-b
a a h r S-d-c
S-d-e
S-d-b-a
S-d-c-a
a G
c
b
e
d f
S h
r
p q
S
S S-d-e-h
S-d S-d-e-r
d e p
S-e S-d-e-h-p
S-p S-d-e-h-q
b c e
S-d-b
a a h r S-d-c
S-d-e
p q
S-d-b-a
S-d-c-a
a G
c
b
e
d f
S h
r
p q
S
S S-d-e-h
S-d S-d-e-r
d e p
S-e S-d-e-h-p
S-p S-d-e-h-q
b c e
S-d-b S-d-e-h-p-q
a a h r S-d-c
S-d-e
p q
S-d-b-a
S-d-c-a
q
a G
c
b
e
d f
S h
r
p q
S
S S-d-e-h
S-d S-d-e-r
d e p
S-e S-d-e-h-p
S-p S-d-e-h-q
b c e
S-d-b S-d-e-h-p-q
a a h r S-d-c S-d-e-r-f
S-d-e
p q f
S-d-b-a
S-d-c-a
q
a G
c
b
e
d f
S h
r
p q
S
S S-d-e-h
S-d S-d-e-r
d e p
S-e S-d-e-h-p
S-p S-d-e-h-q
b c e
S-d-b S-d-e-h-p-q
a a h r S-d-c S-d-e-r-f
S-d-e S-d-e-r-f-c
p q f
S-d-b-a S-d-e-r-f-G
S-d-c-a
q c G
a G
c
b
e
d f
S h
r
p q
S
S S-d-e-h
S-d S-d-e-r
d e p
S-e S-d-e-h-p
S-p S-d-e-h-q
b c e
S-d-b S-d-e-h-p-q
a a h r S-d-c S-d-e-r-f
S-d-e S-d-e-r-f-c
p q f
S-d-b-a S-d-e-r-f-G
S-d-c-a S-d-e-r-f-c-a
q c G
Is it complete?