Search This Blog

Difference Between BFS, DFS, Best First Search, A-Star (A*) Algorithm


Benchmark
BFS
DFS
Best first Search
A*
Pattern
Breadth First Search is a tree or graph traversing (searching) algorithm. In which each node or vertex is explored horizontally.
Depth First Search as name suggests this algorithm traverse a graph in depth (means depth-ward) And uses stack data structure
It is the combination of DFS + BFS
it is the combination of BFS + best First Search
Search
Its search can be done with the help of queue i.e. FIFO implementation.  
Its search can be done with the help of stack i.e. LIFO implementations.  
It support both FIFO & LIFO, It switches in between FIFO and LIFO whenever required
FIFO implementation
Data Structure Type
Queue Data Structure
Stack Data Structure
Priority Queue
Queue Data Structure
Finding Path
It is useful in finding shortest path. It is wide and short
It is not useful in finding shortest path. It is Narrow and long
Useful in finding shortest path, But do not expand all vertex
Useful in finding shortest path by expanding expand all vertex
Speed
It is comparatively slower when compared to DFS.
It is comparatively faster when compared to BFS.    
It is comparatively faster when compared to BFS & DFS.    
It is comparatively faster when compared to Best First Search.
Memory Requirement
Inefficient: It requires comparatively more memory to DFS.  
Efficient: DFS requires comparatively less memory to BFS.  
Efficient: It requires less memory to store the value of vertex
Memory Bounded approach
loop
it will not stuck in loop
It can get stuck in loop
it will not stuck in loop
it will not stuck in loop
Applications Type
Problems solving in graph theory
Puzzles Solving
Games and Web crawlers
GPS map





Post a Comment

0 Comments