GATE Computer ScienceVery hardGATE CS

The same 16-node tree (parent array 0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 9, 9, 10 for nodes 1 to 15, root 0) is to be cut by deleting edges so that every resulting component has an even number of nodes. What is the largest number of edges that can be deleted?

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

Correct answer: B. 5

An edge to a non-root node v may be deleted exactly when the subtree of v has an even size, and this deletion can be done for all such edges simultaneously (the total of 16 is even). The subtree sizes are even for nodes 1 (8), 4 (4), 5 (4), 6 (2) and 10 (2): 5 edges.

More Programming and Data Structures (GATE) questions

Exams that ask this topic