Keep The Heavy Child

DSU on tree answers one subtree query per node in O(nlog⁡n)O(n \log n). What is the counting argument behind the log?

A

Solve the light children first and clear their contribution, keep the heavy child's state, then re-add the light subtrees. Any root-to-node path crosses Θ(n)\Theta(\sqrt n) light edges, so each node is added Θ(n)\Theta(\sqrt n) times overall.

B

Solve the light children first and clear their contribution, keep the heavy child's state, then re-add the light subtrees. Any root-to-node path crosses at most log⁡n\log n light edges, so each node is added O(log⁡n)O(\log n) times overall.

C

Solve the light children first and clear their contribution, keep the heavy child's state, then re-add the light subtrees. Any root-to-node path has depth at most log⁡n\log n after decomposition, so each node is added O(log⁡n)O(\log n) times overall.

D

Solve the heavy child first and clear its contribution, keep the light children's state, then re-add the heavy subtree. Any root-to-node path crosses at most log⁡n\log n light edges, so each node is added O(log⁡n)O(\log n) times overall.