Category
graph algorithms
2 articles
DFS — Depth-First Search: Go Deep Before Going Wide
TLDR: DFS explores a graph by diving as deep as possible along each path before backtracking, using a call stack (recursion) or an explicit stack. It is the go-to algorithm for cycle detection, path finding, topological sort, and connected components...
•16 min read
BFS — Breadth-First Search: Level-by-Level Graph Exploration
TLDR: BFS explores a graph level by level using a FIFO queue, guaranteeing the shortest path in unweighted graphs. Recognize BFS problems by keywords: "shortest path," "minimum steps," or "level order." Time: O(V + E). Space: O(V). Mark nodes visited...
•17 min read
