Professional Documents
Culture Documents
FROM : M . AHMAD
ROLL NO: BSCM-F20-035
What is BFS
graph data structures. It explores all the nodes at the present depth
Pick a node and enqueue all its adjacent nodes into a queue.
Dequeue a node from the queue, mark it as visited and enqueue all its
adjacent nodes into a queue.
Repeat this process until the queue is empty or you meet a goal
Advantages and Disadvantages of BFS
Advantages:
A BFS will find the shortest path between the starting point and any
other reachable node. A depth-first search will not necessarily find
the shortest path.
Disadvantages
A BFS on a binary tree generally requires more memory than a DFS.
What is DFS
Advantages
DFSconsumes very less memory space.
It will reach at the goal node in a less time period than BFS if it traverses in a
right path.
It may find a solution without examining much of search because we may get
the desired solution in the very first go.
Disadvantages
It is possible that may states keep reoccurring. There is no guarantee of
finding the goal node.
THANK YOU