Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2 B

A tree on the vertices C, F, H, L, P, V, W has the arcs V→P, F→P, P→C, F→H, V→L, W→H (each undirected edge is directed as shown). You may reverse the direction of some arcs. What is the minimum number of arcs to reverse so that every vertex can be reached from V?

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

Correct answer: C. 2

In a tree, each edge must point from the parent towards the child (away from the root); an edge pointing towards the root must be reversed. Brute force over reversal sets confirms 2. Counting the arcs that already point away gives 4, which is the wrong quantity.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic