Data Structures & AlgorithmsVery hardICPC regional · tree decomposition

Problem: Which claim about the centroid decomposition of a tree is correct?

  1. A. Its depth is always n
  2. B. It works only on paths
  3. C. It needs O(n^2) memory always
  4. D. Every level has subtrees at most half the size, so the depth is O(log n)

Correct answer: D. Every level has subtrees at most half the size, so the depth is O(log n)

Removing a centroid leaves components of size at most n/2, giving logarithmic depth.

More Coding Interview Problems questions

Exams that ask this topic