Loading Thita. Almost there...
Graph Traversal Patterns - DFS and BFS · 8 of 12
Optimize BFS by searching from both source and target simultaneously. Reduce time complexity significantly.
Access the full theory, code examples, and practice problems.
Start LearningUse DFS to find connected components and count islands in grids. Flood fill and province counting problems.
Use BFS for shortest path in unweighted graphs. Solve word ladder, rotting oranges, and matrix problems.
Master topological sorting using Kahn's BFS algorithm. Solve course schedule and build order problems.
Detect cycles in directed graphs using DFS with coloring (white, gray, black) approach.