Professional Documents
Culture Documents
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
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
DFID
c=1
until solution found do
DFS with depth cutoff c
c = c+1
IDS/DFID Procedure
BDS (Schematic View)