Cycle Detection
Everything on SkillVeris tagged Cycle Detection — collected across the glossary, study notes, blog, and cheat sheets.
15 resources across 1 library
Interview Questions(15)
What is the Two Pointer Technique?
The two pointer technique uses two index variables that move through a data structure — typically a sorted array or a linked list — to solve problems in O(n) t…
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 Kruskal's Algorithm?
Kruskal's algorithm builds a minimum spanning tree by sorting all edges by weight ascending and greedily adding each edge that connects two previously disconne…
What is Union-Find (Disjoint Set Union)?
Union-Find, or Disjoint Set Union (DSU), is a data structure that tracks a collection of non-overlapping sets and answers "are these two elements in the same g…
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…
How Do You Detect a Cycle in a Linked List?
You detect a cycle in a linked list by walking it with two pointers moving at different speeds — a slow pointer advancing one node at a time and a fast pointer…
What is Floyd’s Cycle Detection Algorithm?
Floyd’s cycle detection algorithm, also called the tortoise-and-hare algorithm, finds whether a linked structure contains a cycle and, with a second phase, loc…
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…
What is Topological Sort and How Does Kahn's Algorithm Work?
Topological sort orders the vertices of a directed acyclic graph so that every edge points from an earlier vertex to a later one, and Kahn's algorithm produces…
What is a Disjoint Set Union with Path Compression?
A Disjoint Set Union (also called Union-Find) tracks a collection of non-overlapping sets, supporting find (which set does an element belong to) and union (mer…
Directed vs Undirected Graphs: What is the Difference?
A directed graph has edges with a specific one-way direction from one vertex to another, while an undirected graph has edges that are symmetric, meaning a conn…
What Is the Circular Wait Condition in Deadlock?
The circular wait condition is one of the four necessary conditions for deadlock, and it means there exists a closed chain of two or more processes where each…