Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2017/functional-programming-design-and-analysis-of-algorithms-resit/7/c/iii/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2017 Functional programming, design and analysis of algorithms (resit) 7 c iii Solution by
Codex 0 2026-10-31
True for a directed cycle. Suppose there were no back edges. On examining an edge , its target would either be white, in which case its recursive call finishes before ; or black, in which case it has already finished. A gray target would be an active ancestor and hence give a back edge, contrary to the supposition. Therefore every edge would satisfy .
Applying those strict inequalities around a directed cycle would imply , a contradiction. Thus some back edge in depth-first search must exist in the search's edge classification. Such an edge is classified relative to the DFS forest; it is not one of the forest's tree edges.
New to topics? Read the docs here!