Search Algorithm Comparison
Example Graph
Example Graph:
A
/|\
B C D
/ \
E F
Start node: A
Goal node: F
All edge costs = 1
10-Point Comparison Table
Point DFS DLS BFS Best-First Search IDDFS Bidirectiona
1. Search Style Goes deep into branches
DFS but stops at a depth
Explores levelChooses
by level node closest to goal
DFS (heuristic)
with increasingSearch
depth limit
from start andRec
go
2. Completeness Not always (may loop)
Yes if limit is high enough Yes Not always Yes Yes
3. Optimality No No Yes if costs are equal No Yes if step cost =Yes
1 if both directions
4. Time Complexity O(b^d) O(b^l) O(b^d) O(b^d) O(b^d) O(b^(d/2))
5. Space Complexity O(d) O(l) O(b^d) O(b^d) O(d) O(b^(d/2))
6. Memory Usage Very low Low Very high High Low Medium
7. Path Found (example to F) A->D->F A->D->F (if limit >= 2) A->B->C->D->FA->D->F (if heuristic is good)
A->B->C...->F (gradually) A <-> F meet at
8. Loops Handling May get stuck Avoids looping with limit No loops if tracked May loop if heuristic fails No loop risk Depends on both dir
9. Heuristic Use No No No Yes No No
10. Best For When memory is limited Controlled DFS Finding shortest pathFast guess-based search
Balanced and safe search
Fast on large spa
In