8.1 Graph Representation & Traversal
Adjacency list vs adjacency matrix — when to use which. BFS (level-by-level, shortest path in unweighted graphs). DFS (explore-deep-first, stack-based). Connected components. Bipartite graph check (BFS 2-colouring).
8.2 Cycle Detection & Topological Sort
Cycle detection in undirected graphs (DFS parent tracking, Union-Find). Cycle detection in directed graphs (DFS colouring: white-grey-black). Topological sort: Kahn's algorithm (BFS, in-degree) and DFS-based. Applications: course schedule, build order.
8.3 Shortest Path Algorithms
Dijkstra's (non-negative weights, priority queue). Bellman-Ford (handles negative weights, detects negative cycles). Floyd-Warshall (all-pairs shortest path, O(V³)). 0-1 BFS (deque-based for 0/1 weights). When to use which algorithm.
8.4 Minimum Spanning Tree
Kruskal's algorithm (sort edges + Union-Find). Prim's algorithm (priority queue + greedy). MST properties. Applications: network design, clustering. Why understanding MST matters beyond the algorithm itself.
8.5 Disjoint Set Union (Union-Find)
Union by rank, path compression — near O(1) amortised. Connected components. Cycle detection in undirected graphs. Kruskal's MST. Number of islands (Union-Find approach). Redundant connection. A crucial data structure for graph problems.
8.6 Advanced Graph Problems
Strongly connected components (Kosaraju's, Tarjan's). Articulation points and bridges. Euler path/circuit. Graph colouring. Word ladder (BFS on transformed words). Clone graph. Alien dictionary (topological sort on characters).
Placement relevance: Graph problems are the hardest interview category and appear in 20%+ of product company rounds. Course schedule (topological sort), number of islands (grid DFS/BFS), word ladder, and Dijkstra's algorithm are asked repeatedly at Google, Amazon, Microsoft, and Flipkart.