DFS
Everything on SkillVeris tagged DFS — collected across the glossary, study notes, blog, and cheat sheets.
14 resources across 3 libraries
Study Notes(1)
Cheat Sheets(1)
Interview Questions(12)
BFS vs DFS: What is the Difference?
BFS (breadth-first search) explores a graph level by level using a queue, while DFS (depth-first search) explores as deep as possible along one path before bac…
What is a Graph?
A graph is a data structure made of nodes (vertices) connected by edges, used to model relationships and connections such as networks, maps, or dependencies, a…
What is Topological Sort?
Topological sort produces a linear ordering of the nodes in a directed acyclic graph such that for every directed edge from node A to node B, A appears before…
What is Kosaraju's Algorithm?
Kosaraju's algorithm finds all strongly connected components (SCCs) of a directed graph in O(V + E) time using two depth-first search passes: one on the origin…
What is Tarjan's Algorithm?
Tarjan's algorithm finds all strongly connected components (SCCs) of a directed graph in a single O(V + E) DFS pass by tracking each vertex's discovery time an…
Word Search Problem: How Would You Solve It?
Word search is solved with backtracking DFS: from every cell matching the word's first letter, recursively explore the four orthogonal neighbors while the next…
Number of Islands Problem: How Would You Solve It?
Number of islands is solved by scanning the grid and, each time an unvisited land cell is found, running a flood-fill (DFS or BFS) that marks every orthogonall…
What is the Flood Fill Algorithm?
Flood fill is a traversal algorithm that starts at a given cell in a grid and recursively or iteratively spreads to all orthogonally (or optionally diagonally)…
Course Schedule Problem: How Would You Solve It?
Course schedule is a cycle-detection problem on a directed graph where each course is a node and a prerequisite relationship is a directed edge, and all course…
How Do You Check if a Graph is Bipartite?
A graph is bipartite if its vertices can be split into two groups so that every edge connects a vertex in one group to a vertex in the other, and you check thi…
How Do You Detect a Cycle in a Directed Graph?
You detect a cycle in a directed graph with DFS that tracks each node's state as unvisited, in the current recursion path, or fully processed — a cycle exists…
How Do You Detect a Cycle in an Undirected Graph?
You detect a cycle in an undirected graph with DFS (or BFS) that tracks each node's immediate parent, and a cycle exists if you reach an already-visited neighb…