BFS over DFS in graphs

·

1 min read

BFS

The main funda of BFS is to traverse the entire graph in less time than DFS, BFS traversing helps us to travel multiple nodes at the same time from the same start node. so we use the BFS algorithm to reach the target node in less time.

Whereas DFS(Depth-first-search) as the name suggests control (pointer) goes depth and depth until the target node is found, which means it only traverses only in one direction, unlike BFS. so the DFS algorithm is not good practice for problems like Rotten oranges in various coding platforms