Start with the full tree. Find its centroid . Mark as processed. Split the tree into components by removing . Recursively find centroids of each component. Store parent-child relationships in the decomposition tree. Each recursive call works on a tree with at most nodes.
The recursion depth is , and each level processes all nodes once. You recompute subtree sizes for each component. Total time: . You rebuild size arrays for each component, but the halving keeps it logarithmic. Space is for the tree structure.
Space complexity is for the data structures used.