Syntax error Applications of DFS and BFS in Data Structures

Applications of DFS and BFS in Data Structures



Here we will see what are the different applications of DFS and BFS algorithms of a graph?

The DFS or Depth First Search is used in different places. Some common uses are −

  • If we perform DFS on unweighted graph, then it will create minimum spanning tree for all pair shortest path tree
  • We can detect cycles in a graph using DFS. If we get one back-edge during BFS, then there must be one cycle.
  • Using DFS we can find path between two given vertices u and v.
  • We can perform topological sorting is used to scheduling jobs from given dependencies among jobs. Topological sorting can be done using DFS algorithm.
  • Using DFS, we can find strongly connected components of a graph. If there is a path from each vertex to every other vertex, that is strongly connected.

Like DFS, the BFS (Breadth First Search) is also used in different situations. These are like below −

  • In peer-to-peer network like bit-torrent, BFS is used to find all neighbor nodes
  • Search engine crawlers are used BFS to build index. Starting from source page, it finds all links in it to get new pages
  • Using GPS navigation system BFS is used to find neighboring places.
  • In networking, when we want to broadcast some packets, we use the BFS algorithm.
  • Path finding algorithm is based on BFS or DFS.
  • BFS is used in Ford-Fulkerson algorithm to find maximum flow in a network.
Updated on: 2019-08-27T12:25:37+05:30

19K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements