Professional Documents
Culture Documents
Dfs N Bfs
Dfs N Bfs
1 Definition BFS, stands for Breadth First Search. DFS, stands for Depth First Search.
Data BFS uses Queue to find the shortest DFS uses Stack to find the shortest
2 structure path. path.
Source BFS is better when target is closer to DFS is better when target is far from
3 Source. source.
Suitablity for As BFS considers all neighbour so it is DFS is more suitable for decision tree.
decision not suitable for decision tree used in As with one decision, we need to
tree puzzle games. traverse further to augment the
4 decision. If we reach the conclusion,
we won.
Time Time Complexity of BFS = O(V+E) where Time Complexity of DFS is also O(V+E)
Complexity V is vertices and E is edges. where V is vertices and E is edges.
5
Thank you