You are on page 1of 30

UNIT II

Search Strategies – Uninformed search


Uninformed vs Informed search

• Uninformed search strategies


• Also known as "blind search," use no information about the likely "direction" of
the goal node(s)
• do not have any idea of the problem domain.
• Uninformed search methods: breadth-first search, depth-first search, depth-
limited search, uniform-cost, depth-first iterative deepening and bidirectional
search
• Informed search strategies
• Also known as "heuristic search," informed search strategies use information
about the domain to (try to) (usually) head in the general direction of the goal
node(s).
• Informed search methods: hill climbing, best-first, greedy search, and A*
Uninformed search strategies

Outline of a search algorithm


1. Initialize: Set OPEN = {s}, CLOSED = { }
2. Fail: If OPEN = { }, then terminate with failure
3. Select: Select a state, n, from OPEN and save in CLOSED
4. Terminate: If n ∈ G, terminate with success
5. Expand:
Generate the successors of n using O. For each successor, m,
insert m in OPEN only if m ∉ [OPEN ∪ CLOSED]
6. Loop: Go To Step 2.
BFS VS DFS
BFS
- In above algorithm, if OPEN = QUEUE (FIFO ), its breadth-first search

DFS
- In above algorithm, if OPEN = STACK (LIFO ), its depth-first search
Examples BFS and DFS
EXECUTION OF BFS
1. OPEN ={A}, CLOSED = {}
2. OPEN = {B,C,D}, CLOSED = {A}
3. OPEN = {C,D,E,F,G}, CLOSED = (A,B}
4. OPEN = {D,E,F,G}, CLOSED = {A,B,C}
5. OPEN = {E,F,G,H}. CLOSED = {A,B,C,D}
6. OPEN = {F,G,H,I,J}, CLOSED = {A,B,C,D,E}
7. OPEN = {G,H,I,J}, CLOSED = {A,B,C,D,E,F}
8. OPEN = {H,I,J}, CLOSED = {A,B,C,D,E,F,G}
9. Goal Node H Found. Can Terminate with Path from A to H.
EXECUTION OF DFS

1. OPEN ={A}, CLOSED = {}


2. OPEN = {B,C,D}, CLOSED = {A}
3. OPEN = {E,F,G,C,D}, CLOSED = (A,B}
4. OPEN = {I,J,F,G,C,D}, CLOSED = {A,B,E}
5. Goal Node I Found.
Can Terminate with Path from A to I
PROBLEM 2: BFS AND DFS

FIND THE SOLUTION BY PERFORMING BFS AND DFS


TRY IT OUT: BFS AND DFS

FIND THE COST OF SOLUTION BUSING BFS AND DFS

C E
4

B G
5
5
4

S A D
3 3
Evaluating Search strategies
Completeness: Guarantees finding a solution whenever one exists
Optimality/Admissibility: If a solution is found, is it guaranteed to
be an optimal one ? That is, is it the one with minimal cost?
Analysis: What is the search cost associated with the time and
memory required to find a solution?
Time complexity:
• How long (worst or average case) does it take to find a solution?
• Usually measured in terms of the number of nodes expanded
Space complexity:
• How much space is used by the algorithm?
• Usually measured in terms of the maximum size of the "nodes" List
during the search
Important parameters

• Maximum number of successors of any


state of the search tree
• branching factor b of the search tree
• Minimal length of path in the state space
between the initial and a goal state
• depth d of the shallowest goal node in
the search tree
• Maximum depth m of the state space
Worst-case Analysis (Big O notation)
• Let f,g :
We say, the growth rate of f is bounded above by the growth rate of g
I.e. f(n) = O(g(n)) [Read f(n) is big oh of g(n)]
• Precisely f(n) = O(g(n)) means that there are positive numbers c
and n0 such that
• |f(n) | <= c |g(n)| for all n >= n0
Example:
Algorithm A: Sort three numbers A,B,C;
Input size (n) = 3
6 Possible inputs: ABC,ACB,BAC,BCA,CAB,CBA
BFS Analysis
• Complete: Yes
• Optimum: Yes
• Analysis:
• Time (no of expanded nodes/worst case)= f(b) =
BFS Analysis
• Space:
DFS Analysis
DFS Analysis
Depth-First Iterative Deepening (DFID)/IDS

DFID

c=1
until solution found do
DFS with depth cutoff c
c = c+1
IDS/DFID Procedure
BDS (Schematic View)

Figure: A schematic view of a bidirectional search that is about to succeed


when a branch from the start node meets a branch from the goal node
DFID/IDS Analysis
DFID/IDS Analysis
DFID/IDS Analysis
Bi-directional search (BDS)
Requirement
• Operators are reversible
• If O1: State A --> State B Then there exist O2 such that
O2: State B -> State A
• One should be able to generate predecessor states where the
predecessors of node n are all the nodes that have n as successor
• Examples: 8-puzzle, 15-puzzle, path planning etc.
• Algorithm:
• Bidirectional search involves alternate searching from the start state toward
the goal and from the goal state toward the start.
• The algorithm stops when the frontiers (OPEN Lists) intersect, I.e., finding a
common node m . Construct path from start to Goal via m.
BDS Analysis
BDS Analysis
Figure: Evaluation of tree-search strategies. b is the branching factor; d is the depth of the shallowest solution;
m is the maximum depth of the search tree; l is the depth limit

You might also like