You are on page 1of 73

Lecture 03

Uninformed Search
Dr. Humera Farooq

© Tariq 2017 Department of Computer Science | Bahria University 1


Outline
• Searching Strategies
• Uninform Search Strategies
– Breadth First Search
– Depth First Search
– Uniform cost Search

© Tariq 2017 Department of Computer Science | Bahria University 2


Outline: Searching Strategies
• Uninformed Search Strategies
– Breadth First Search
– Depth First Search
– Uniform cost Search
– Iterative Deepening Search
– Depth-Limit Search
– Bidirectional Search
• Informed Search Strategies
– Best First Search
– Greedy Search
– A* Search
• Local Search
• Adversarial Search

© Tariq 2017 Department of Computer Science | Bahria University 3


Uninformed Search Strategies
• A search strategy is defined by picking the order of node expansion
• Strategies are evaluated along the following dimensions:
– completeness: does it always find a solution if one exists?
– time complexity: number of nodes generated
– space complexity: maximum number of nodes in memory
– optimality: does it always find a least-cost solution?
• Time and space complexity are measured in terms of
– b: maximum branching factor of the search tree
– d: depth of the least-cost solution
– m: maximum depth of the state space (may be ∞)
• Uninformed (blind) strategies use only the information available in
the problem definition

© Tariq 2017 Department of Computer Science | Bahria University 4


Breadth-First Search (BFS)

• Root node is expanded first  successor of


root node  their successors
• All nodes are expanded at a given depth in the
search tree before any nodes at the next level
are expanded
• Easy to implement by using FIFO queue

© Tariq 2017 Department of Computer Science | Bahria University 5


Breadth-First Search (BFS)
generalSearch(problem, queue)
S
# of nodes tested: 0, expanded: 0 start
expnd. node Frontier list
{S} 5 2 4

A B C

9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 6


Breadth-First Search (BFS)
generalSearch(problem, queue)
S
# of nodes tested: 1, expanded: 1 start
expnd. node Frontier list
{S} 5 2 4
S not goal {A,B,C}
A B C

9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 7


Breadth-First Search (BFS)
generalSearch(problem, queue)
S
# of nodes tested: 2, expanded: 2 start
expnd. node Frontier list
{S} 5 2 4
S {A,B,C}
A B C
A not goal {B,C,D,E}
9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 8


Breadth-First Search (BFS)
generalSearch(problem, queue)
S
# of nodes tested: 3, expanded: 3 start
expnd. node Frontier list
{S} 5 2 4
S {A,B,C}
A B C
A {B,C,D,E}
B not goal {C,D,E,G}
9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 9


Breadth-First Search (BFS)
generalSearch(problem, queue)
S
# of nodes tested: 4, expanded: 4 start
expnd. node Frontier list
{S} 5 2 4
S {A,B,C}
A B C
A {B,C,D,E}
B {C,D,E,G}
9 4 6 2
C not goal {D,E,G,F}
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 10


Breadth-First Search (BFS)
generalSearch(problem, queue)
S
# of nodes tested: 5, expanded: 5 start
expnd. node Frontier list
{S} 5 2 4
S {A,B,C}
A B C
A {B,C,D,E}
B {C,D,E,G}
9 4 6 2
C {D,E,G,F}
6 G 1
D not goal {E,G,F,H} D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 11


Breadth-First Search (BFS)
generalSearch(problem, queue)
S
# of nodes tested: 6, expanded: 6 start
expnd. node Frontier list
{S} 5 2 4
S {A,B,C}
A B C
A {B,C,D,E}
B {C,D,E,G}
9 4 6 2
C {D,E,G,F}
6 G 1
D {E,G,F,H} D E goal F
E not goal {G,F,H,G}
7

© Tariq 2017 Department of Computer Science | Bahria University 12


Breadth-First Search (BFS)
generalSearch(problem, queue)
S
# of nodes tested: 7, expanded: 6 start
expnd. node Frontier list
{S} 5 2 4
S {A,B,C}
A B C
A {B,C,D,E}
B {C,D,E,G}
9 4 6 2
C {D,E,G,F}
6 G 1
D {E,G,F,H} D E goal F
E {G,F,H,G}
G goal {F,H,G} no expand 7

© Tariq 2017 Department of Computer Science | Bahria University 13


Breadth-First Search (BFS)
generalSearch(problem, queue)
S
# of nodes tested: 7, expanded: 6 start
expnd. node Frontier list
{S} 5 2 4
S {A,B,C}
A B C
A {B,C,D,E}
B {C,D,E,G}
9 4 6 2
C {D,E,G,F}
6 G 1
D {E,G,F,H} D E goal F
E {G,F,H,G}
G {F,H,G} 7
path: S,B,G
H cost: 8

© Tariq 2017 Department of Computer Science | Bahria University 14


Properties of Breadth-First Search
• Completeness: Yes, if b is finite
• Optimality: Yes (assuming cost = 1 per step)
• Time complexity: 1+b+b2+…+bd = O(b d),
i.e., exponential in d
• Space complexity: O(b d)

b – maximum branching factor of the search tree


d – depth of the least-cost solution
m – maximum depth of the state space (may be infinite)

© Tariq 2017 Department of Computer Science | Bahria University 15


Exponential Growth
Depth Nodes Time Memory
2 110 0.11 millisecond 107 kbytes
4 11,110 11 millisecond 10.6 megabytes
6 106 1.1 seconds 1 gigabyte
8 108 2 minutes 103 gigabytes
10 1010 3 hours 10 terabytes
12 1012 13 days 1 petabyte
14 1014 3.5 years 99 petabytes
16 1016 350 years 10 exabytes

Time and memory requirements for breadth-first search,


assuming a branching factor of 10, 100 bytes per node and
searching 1000 nodes/second
© Tariq 2017 Department of Computer Science | Bahria University 16
Depth-First Search (DFS)
• Expands the deepest node in the current
frontier of the search tree until the nodes
have no successors, then backs up to the next
deepest node that still has unexplored
successors.
• Use LIFO queue
– The most recently generated node is chosen for
expansion, the deepest unexpanded node
• Use recursive

© Tariq 2017 Department of Computer Science | Bahria University 17


Depth-First Search (DFS)
generalSearch(problem, stack)
S
# of nodes tested: 0, expanded: 0 start
expnd. node Frontier
{S} 5 2 4

A B C

9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 18


Depth-First Search (DFS)
generalSearch(problem, stack)
S
# of nodes tested: 1, expanded: 1 start
expnd. node Frontier
{S} 5 2 4
S not goal {A,B,C}
A B C

9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 19


Depth-First Search (DFS)
generalSearch(problem, stack)
S
# of nodes tested: 2, expanded: 2 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A B C
A not goal {D,E,B,C}
9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 20


Depth-First Search (DFS)
generalSearch(problem, stack)
S
# of nodes tested: 3, expanded: 3 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A B C
A {D,E,B,C}
D not goal {H,E,B,C}
9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 21


Depth-First Search (DFS)
generalSearch(problem, stack)
S
# of nodes tested: 4, expanded: 4 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A B C
A {D,E,B,C}
D {H,E,B,C}
9 4 6 2
H not goal {E,B,C}
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 22


Depth-First Search (DFS)
generalSearch(problem, stack)
S
# of nodes tested: 5, expanded: 5 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A B C
A {D,E,B,C}
D {H,E,B,C}
9 4 6 2
H {E,B,C}
6 G 1
E not goal {G,B,C} D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 23


Depth-First Search (DFS)
generalSearch(problem, stack)
S
# of nodes tested: 6, expanded: 5 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A B C
A {D,E,B,C}
D {H,E,B,C}
9 4 6 2
H {E,B,C}
6 G 1
E {G,B,C} D E goal F
G goal {B,C} no expand
7

© Tariq 2017 Department of Computer Science | Bahria University 24


Depth-First Search (DFS)
generalSearch(problem, stack)
S
# of nodes tested: 6, expanded: 5 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A B C
A {D,E,B,C}
D {H,E,B,C}
9 4 6 2
H {E,B,C}
6 G 1
E {G,B,C} D E goal F
G {B,C}
7
path: S,A,E,G
H cost: 15

© Tariq 2017 Department of Computer Science | Bahria University 25


Properties of Depth-First Search
• Completeness: No, fails in infinite state-space
(yes if finite state space)
• Time complexity: O(b m)
• Space complexity: O(bm)
• Optimality: No

Remember:
b = branching factor
m = max depth of search tree
© Tariq 2017 Department of Computer Science | Bahria University 26
Uniform-Cost Search (UCS)

• Use a “Priority Queue” to order nodes on the


Frontier list, sorted by path cost
• Let g(n) = cost of path from start node s to
current node n
• Sort nodes by increasing value of g

27
© Tariq 2017 Department of Computer Science | Bahria University 27
Uniform-Cost Search (UCS)
generalSearch(problem, priorityQueue)
S
# of nodes tested: 0, expanded: 0 start
expnd. node Frontier list
{S} 5 2 4

A B C

9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 28


Uniform-Cost Search (UCS)
generalSearch(problem, priorityQueue)
S
# of nodes tested: 1, expanded: 1 start
expnd. node Frontier list
{S:0} 5 2 4
S not goal {B:2,C:4,A:5}
A B C

9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 29


Uniform-Cost Search (UCS)
generalSearch(problem, priorityQueue)
S
# of nodes tested: 2, expanded: 2 start
expnd. node Frontier list
{S} 5 2 4
S {B:2,C:4,A:5}
A B C
B not goal {C:4,A:5,G:2+6}
9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 30


Uniform-Cost Search (UCS)
generalSearch(problem, priorityQueue)
S
# of nodes tested: 3, expanded: 3 start
expnd. node Frontier list
{S} 5 2 4
S {B:2,C:4,A:5}
A B C
B {C:4,A:5,G:8}
C not goal {A:5,F:4+2,G:8}
9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 31


Uniform-Cost Search (UCS)
generalSearch(problem, priorityQueue)
S
# of nodes tested: 4, expanded: 4 start
expnd. node Frontier list
{S} 5 2 4
S {B:2,C:4,A:5}
A B C
B {C:4,A:5,G:8}
C {A:5,F:6,G:8}
9 4 6 2
A not goal {F:6,G:8,E:5+4,
D:5+9} 6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 32


Uniform-Cost Search (UCS)
generalSearch(problem, priorityQueue)
S
# of nodes tested: 5, expanded: 5 start
expnd. node Frontier list
{S} 5 2 4
S {B:2,C:4,A:5}
A B C
B {C:4,A:5,G:8}
C {A:5,F:6,G:8}
9 4 6 2
A {F:6,G:8,E:9,D:14}
6 G 1
F not goal {G:4+2+1,G:8,E:9, D E goal F
D:14}
7

© Tariq 2017 Department of Computer Science | Bahria University 33


Uniform-Cost Search (UCS)
generalSearch(problem, priorityQueue)
S
# of nodes tested: 6, expanded: 5 start
expnd. node Frontier list
{S} 5 2 4
S {B:2,C:4,A:5}
A B C
B {C:4,A:5,G:8}
C {A:5,F:6,G:8}
9 4 6 2
A {F:6,G:8,E:9,D:14}
6 G 1
F {G:7,G:8,E:9,D:14} D E goal F
G goal {G:8,E:9,D:14}
no expand 7

© Tariq 2017 Department of Computer Science | Bahria University 34


Uniform-Cost Search (UCS)
generalSearch(problem, priorityQueue)
S
# of nodes tested: 6, expanded: 5 start
expnd. node Frontier list
{S} 5 2 4
S {B:2,C:4,A:5}
A B C
B {C:4,A:5,G:8}
C {A:5,F:6,G:8}
9 4 6 2
A {F:6,G:8,E:9,D:14}
6 G 1
F {G:7,G:8,E:9,D:14} D E goal F
G {G:8,E:9,D:14}
7
path: S,C,F,G
H cost: 7

© Tariq 2017 Department of Computer Science | Bahria University 35


Properties of Uniform-Cost Search
• Complete: Yes if arc costs > 0.
• Optimal: Yes
• Time and space complexity: O(bd) (i.e.,exponential)
– d is the depth of the solution
– b is the branching factor at each non-leaf node

• More precisely, time and space complexity is


O(bC*/ε ) where all edge costs > 0, and C* is the
best goal path cost

© Tariq 2017 Department of Computer Science | Bahria University 36


Iterative-Deepening Search (IDS)

• requires modification to DFS search algorithm:


– do DFS to depth 1
and treat all children of the start node as leaves
– if no solution found, do DFS to depth 2
– repeat by increasing “depth bound” until a
solution found

• Start node is at depth 0

© Tariq 2017 Department of Computer Science | Bahria University 37


Iterative-Deepening Search (IDS)

deepeningSearch(problem)
S
depth: 1, # of nodes expanded: 0, tested: 0 start
expnd. node Frontier
{S} 5 2 4

A B C

9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 39


Iterative-Deepening Search (IDS)

deepeningSearch(problem)
S
depth: 1, # of nodes tested: 1, expanded: 1 start
expnd. node Frontier
{S} 5 2 4
S not goal {A,B,C}
A B C

9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 40


Iterative-Deepening Search (IDS)

deepeningSearch(problem)
S
depth: 1, # of nodes tested: 2, expanded: 1 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A not goal {B,C} no expand A B C

9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 41


Iterative-Deepening Search (IDS)

deepeningSearch(problem)
S
depth: 1, # of nodes tested: 3, expanded: 1 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A {B,C} A B C
B not goal {C} no expand
9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 42


Iterative-Deepening Search (IDS)

deepeningSearch(problem)
S
depth: 1, # of nodes tested: 4, expanded: 1 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A {B,C} A B C
B {C}
C not goal { } no expand-FAIL 9 4 6 2
6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 43


Iterative-Deepening Search (IDS)

deepeningSearch(problem)
S
depth: 2, # of nodes tested: 4(1), expanded: 2 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A {B,C} A B C
B {C}
C {} 9 4 6 2
S no test {A,B,C} 6 G 1
D E goal F

© Tariq 2017 Department of Computer Science | Bahria University 44


Iterative-Deepening Search (IDS)

deepeningSearch(problem)
S
depth: 2, # of nodes tested: 4(2), expanded: 3 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A {B,C} A B C
B {C}
C {} 9 4 6 2
S {A,B,C} 6 G 1
D E goal F
A no test {D,E,B,C}
7

© Tariq 2017 Department of Computer Science | Bahria University 45


Iterative-Deepening Search (IDS)

deepeningSearch(problem)
S
depth: 2, # of nodes tested: 5(2), expanded: 3 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A {B,C} A B C
B {C}
C {} 9 4 6 2
S {A,B,C} 6 G 1
D E goal F
A {D,E,B,C}
D not goal {E,B,C} no expand 7

© Tariq 2017 Department of Computer Science | Bahria University 46


Iterative-Deepening Search (IDS)

deepeningSearch(problem)
S
depth: 2, # of nodes tested: 6(2), expanded: 3 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A {B,C} A B C
B {C}
C {} 9 4 6 2
S {A,B,C} 6 G 1
D E goal F
A {D,E,B,C}
D {E,B,C} 7
E not goal {B,C} no expand
H

© Tariq 2017 Department of Computer Science | Bahria University 47


Iterative-Deepening Search (IDS)

deepeningSearch(problem)
S
depth: 2, # of nodes tested: 6(3), expanded: 4 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A {B,C} A B C
B {C}
C {} 9 4 6 2
S {A,B,C} 6 G 1
D E goal F
A {D,E,B,C}
D {E,B,C} 7
E {B,C}
B no test {G,C} H

© Tariq 2017 Department of Computer Science | Bahria University 48


Iterative-Deepening Search (IDS)
deepeningSearch(problem)
S
depth: 2, # of nodes tested: 7(3), expanded: 4 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A {B,C} A B C
B {C}
C {} 9 4 6 2
S {A,B,C} 6 G 1
D E goal F
A {D,E,B,C}
D {E,B,C} 7
E {B,C}
B {G,C} H
G goal {C} no expand

© Tariq 2017 Department of Computer Science | Bahria University 49


Iterative-Deepening Search (IDS)
deepeningSearch(problem)
S
depth: 2, # of nodes tested: 7(3), expanded: 4 start
expnd. node Frontier
{S} 5 2 4
S {A,B,C}
A {B,C} A B C
B {C}
C {} 9 4 6 2
S {A,B,C} 6 G 1
D E goal F
A {D,E,B,C}
D {E,B,C} 7
E {B,C} path: S,B,G
B {G,C} H cost: 8
G {C}

© Tariq 2017 Department of Computer Science | Bahria University 50


Properties of Iterative Deepening Search

• Space complexity = O(bd)


• Time Complexity = O(bd)
Complete?
– Yes
• Optimal
– Only if path cost is a non-decreasing function of depth

• IDS combines the small memory footprint of DFS,


and has the completeness guarantee of BFS
© Tariq 2017 Department of Computer Science | Bahria University 51
Depth-Limited Search (DLS)
DLS is a depth-first search with a predetermined depth
limit l
Implementation:
Nodes at depth l are treated as if they have no
successors.
Complete: if cutoff chosen appropriately then it is
guaranteed to find a solution.
Optimal: it does not guarantee to find the least-cost
solution (If choosing l >d )
© Tariq 2017 Department of Computer Science | Bahria University 52
Depth-Limited Search (DLS)
Given the following state space (tree search), give the sequence of
visited nodes when using DLS (Limit = 2):

Limit = 0 A

Limit = 1 B C D E

Limit = 2 F G H I J

K L M N

© Tariq 2017 Department of Computer Science | Bahria University 53


Depth-Limited Search (DLS)
 A,

B C D E

Limit = 2

© Tariq 2017 Department of Computer Science | Bahria University 54


Depth-Limited Search (DLS)
 A,B,

B C D E

Limit = 2 F G

© Tariq 2017 Department of Computer Science | Bahria University 55


Depth-Limited Search (DLS)
 A,B,F,

B C D E

Limit = 2 F G

© Tariq 2017 Department of Computer Science | Bahria University 56


Depth-Limited Search (DLS)
 A,B,F,
 G,

B C D E

Limit = 2 F G

© Tariq 2017 Department of Computer Science | Bahria University 57


Depth-Limited Search (DLS)
 A,B,F,
 G,
 C,
A

B C D E

Limit = 2 F G H

© Tariq 2017 Department of Computer Science | Bahria University 58


Depth-Limited Search (DLS)
 A,B,F,
 G,
 C,H,
A

B C D E

Limit = 2 F G H

© Tariq 2017 Department of Computer Science | Bahria University 59


Depth-Limited Search (DLS)
 A,B,F,
 G,
 C,H,
 D, A

B C D E

Limit = 2 F G H I J

© Tariq 2017 Department of Computer Science | Bahria University 60


Depth-Limited Search (DLS)
 A,B,F,
 G,
 C,H,
 D,I A

B C D E

Limit = 2 F G H I J

© Tariq 2017 Department of Computer Science | Bahria University 61


Depth-Limited Search (DLS)
 A,B,F,
 G,
 C,H,
 D,I A
 J,
B C D E

Limit = 2 F G H I J

© Tariq 2017 Department of Computer Science | Bahria University 62


Depth-Limited Search (DLS)
 A,B,F,
 G,
 C,H,
 D,I A
 J,
 E B C D E

Limit = 2 F G H I J

© Tariq 2017 Department of Computer Science | Bahria University 63


Depth-Limited Search (DLS)
 A,B,F,
 G,
 C,H,
 D,I A
 J,
 E, Failure B C D E

Limit = 2 F G H I J

© Tariq 2017 Department of Computer Science | Bahria University 64


Depth-Limited Search (DLS)
 DLS algorithm returns Failure (no solution)
 The reason is that the goal is beyond the limit (Limit =2): the goal
depth is (d=4)

B C D E

Limit = 2 F G H I J

K L M N

© Tariq 2017 Department of Computer Science | Bahria University 65


How to choose depth limit l
• The unbounded tree problem appeared in DFS can be
fixed by imposing a limit on the depth that DFS can reach,
this limit we will call depth limit l, this solves the infinite
path problem.
• E.g. Romania case, 20 cities
– The longest is 19, so l can be 19
– From study, cities can be reached by other cities by 9 steps
(diameter)
– If diameter is known, more efficient depth-limited search
• Depth limit search can be terminated by
– Failure  no solution
– Cutoff  no solution within the depth limit
© Tariq 2017 Department of Computer Science | Bahria University 66
Depth-Limited Search (DLS)
Performance Measure:
Completeness: The limited path introduces another problem which is the
case when we choose l < d, in which is our DLS will never reach a goal, in
this case we can say that DLS is not complete.
Optimality: One can view DFS as a special case of the depth DLS, that DFS is
DLS with l = infinity.
DLS is not optimal even if l > d.
Time Complexity: O(bl)
Space Complexity: O(bl)
Conclusion:
DLS can be used when the there is a prior knowledge to the problem, which
is always not the case, Typically, we will not know the depth of the
shallowest goal of a problem unless we solved this problem before.

© Tariq 2017 Department of Computer Science | Bahria University 67


Bidirectional search

Start Goal

© Tariq 2017 Department of Computer Science | Bahria University 68


Bidirectional search
• Both search forward from initial state, and
backwards from goal.
• Stop when the two searches meet in the middle.
• Problem: how do we search backwards from goal?
– predecessor of node n = all nodes that have n as successor
– this may not always be easy to compute!

– if several goal states


– Efficient way to check whether a given node belongs to the other
search tree.
– Select a given search algorithm for each half.
© Tariq 2017 Department of Computer Science | Bahria University 69
Bidirectional search
1. QUEUE1 <-- path only containing the root;
QUEUE2 <-- path only containing the goal;

2. WHILE both QUEUEs are not empty


AND QUEUE1 and QUEUE2 do NOT share a state

DO remove their first paths;


create their new paths (to all children);
reject their new paths with loops;
add their new paths to back;

3. IF QUEUE1 and QUEUE2 share a state


THEN success;
ELSE failure;

© Tariq 2017 Department of Computer Science | Bahria University 70


Bidirectional Search

Initial State Final State

d/2

© Tariq 2017 Department of Computer Science | Bahria University 71


Bidirectional search
• Completeness: Yes,

• Time complexity: 2*O(b d/2) = O(b d/2)

• Space complexity: O(b d/2)

• Optimality: Yes

© Tariq 2017 Department of Computer Science | Bahria University 72


Comparison Uninformed Search Strategies

© Tariq 2017 Department of Computer Science | Bahria University 73


Conclusions
• Interesting problems can be cast as search
problems, but you’ve got to set up state space
• Problem formulation usually requires
abstracting away real world details to define a
state space that can feasibly be explored

© Tariq 2017 Department of Computer Science | Bahria University 74

You might also like