Master all types of Graph Algorithms and their Sample Code

Y Tech
2 min readFeb 23, 2022

I have conducted hundreds of interviews. I noticed very often, the candidate could successfully identify the problem by using a graph approach, but failed to implement the algorithm. In this post, I will discuss the common types of graph algorithms, along with their sample code.

  1. Standard DFS (pre-order and post-order)
  2. Standard BFS
  3. Topological sort with BFS
  4. Topological sort with DFS
  5. Dijkstra’s Algorithm

--

--