Graph Topics
Master essential graph problems and patterns frequently asked in interviews.
- 01 BFS & DFS Traversals Basic graph traversal using BFS and DFS, both iterative & recursive
- 02 Connected Components / Island Counting DFS/BFS pattern to count separate components in a graph or grid
- 03 Topological Sorting DFS or Kahn's algorithm for DAG ordering
- 04 Shortest Path (Dijkstra / BFS) Find shortest distances using BFS (unweighted) or Dijkstra (weighted)
- 05 Minimum Spanning Tree (MST) Kruskal's or Prim's algorithm for MST construction
WONDERING, HOW DOES IT COVER PATTERNS?
These problems cover the most important graph patterns for
interviews:
BFS & DFS Traversals →
Fundamental traversal patterns for graphs, trees, and grids.
Connected Components / Island Counting
→
DFS/BFS flood fill pattern to explore separate components.
Topological Sorting →
DFS post-order or queue-based ordering of DAG nodes.
Shortest Path (Dijkstra / BFS) →
Single-source shortest path using BFS for unweighted or Dijkstra for
weighted graphs.
Minimum Spanning Tree (MST) →
Greedy algorithms (Prim/Kruskal) to connect all nodes with minimum
cost.
Together, they ensure you understand
traversals, component counting, DAG ordering, shortest path finding,
and MST construction
in graph problems.