Data Structures & AlgorithmsHardICPC regional · Codeforces Div2 D

Problem: A directed graph has vertices 0–3 with arcs 0→1, 1→2, 2→1, 2→3. Using DFS from vertex 0 with children visited in increasing order, which vertex is the first to be finished (post-order first)?

  1. A. 4
  2. B. 3
  3. C. 2
  4. D. 5

Correct answer: B. 3

The first vertex to finish is the deepest one reached first: 3 has no outgoing arcs, so it finishes before 2 and the rest of the recursion.

More Coding Interview Problems questions

Exams that ask this topic