Search This Blog

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

Difference Between BFS & DFS Algorithm


Benchmark
BFS
DFS
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
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.  
Data Structure Type
Queue Data Structure
Stack 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
Speed
It is comparatively slower when compared to DFS.
It is comparatively faster when compared to BFS.    
Memory Requirement
Inefficient: It requires comparatively more memory to DFS.  
Efficient: DFS requires comparatively less memory to BFS.  
loop
it will not stuck in loop
It can get stuck in loop
Applications Type
Problems solving in graph theory
Puzzles Solving



Difference Between Best First & A-Star ( A*) Algorithm

Benchmark
Best first Search
A*
Pattern
It is the combination of DFS + BFS
it is the combination of BFS + best First Search
Search
It support both FIFO & LIFO, It switches in between FIFO and LIFO whenever required
FIFO implementation
Data Structure Type
Priority Queue
Queue Data Structure
Finding Path
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 faster when compared to BFS & DFS.    
It is comparatively faster when compared to Best First Search.
Memory Requirement
Inefficient: It requires memory to to store the value of vertex
Memory Bounded approch
loop
it will not stuck in loop
it will not stuck in loop
Applications Type
Games and Web crawlers
GPS map
 


 


Post a Comment

0 Comments