Questions: Cycle Detection in Directed Graphs

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

During a DFS-based cycle detection on a directed graph, the algorithm follows an edge and arrives at a vertex that has already been completely processed (colored black). What should the algorithm conclude?

AA cycle has been found, because the vertex was already visited
BNo cycle is indicated — a finished vertex means its entire subtree was acyclic
CThe graph contains a back edge, which always signals a cycle
DThe algorithm has encountered a cross edge, which means the graph is disconnected
Question 2 Multiple Choice

Why is a two-color scheme (visited / unvisited) insufficient for cycle detection in directed graphs?

ATwo colors cannot represent the starting vertex of DFS
BTwo colors cannot distinguish a vertex that is a finished descendant from a vertex that is an active ancestor on the current path
CDFS requires at least three colors to handle disconnected graphs
DTwo colors work for undirected graphs but directed graphs require more states due to edge directionality
Question 3 True / False

In DFS-based cycle detection on a directed graph, discovering a back edge (an edge pointing to a gray vertex) is both a necessary and sufficient condition for the graph to contain a cycle.

TTrue
FFalse
Question 4 True / False

If DFS encounters an edge to a fully-processed (black) vertex, this indicates a cycle exists in the directed graph.

TTrue
FFalse
Question 5 Short Answer

Explain why encountering a gray vertex during DFS indicates a cycle, while encountering a black vertex does not, and why this distinction requires three colors rather than two.

Think about your answer, then reveal below.