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.
- Standard DFS (pre-order and post-order)
- Standard BFS
- Topological sort with BFS
- Topological sort with DFS
- Dijkstra’s Algorithm