Intermediate Data Structures & Algorithms
Q61 / 100

What is a cycle in a directed graph, and how is it detected?

Correct! Well done.

Incorrect.

The correct answer is B) A path from a vertex back to itself; detected using DFS with a recursion stack (gray coloring)

B

Correct Answer

A path from a vertex back to itself; detected using DFS with a recursion stack (gray coloring)

Explanation

In directed graph DFS, a back edge (edge to a node currently on the recursion stack, i.e., gray/in-progress) indicates a cycle. Three-color DFS is the classic approach.

Progress
61/100