Some tree problems ask about all paths, not root-to-leaf or parent-to-child. Counting paths of a specific length across the entire tree is expensive with DFS alone. Checking all pairs takes too long. Centroid decomposition splits the problem.
Instead of checking all pairs directly, you process paths through strategic nodes called centroids.
Each path passes through at least one centroid in the decomposition, so you count paths at each centroid and combine results. If a problem involves path properties (length, sum, XOR) affecting the whole tree, centroid decomposition might be your solution.
Space complexity is for the data structures used.