Why it matters

Centroid decomp enables O(n log n) tree algorithms.

Advertisement

The architecture

Centroid: node whose removal leaves subtrees ≤ n/2.

Recursively decompose each subtree.

Centroid decompFind centroidbalanced splitProcess paths through centroidcount/sum/etcRecurseon subtreeslog n levels; O(n log n) total work for many problems
Centroid decomp.
Advertisement

How it works end to end

Applications: path counting, distance queries.

Implementation: recursively find + process.

Combines with other techniques (BFS from centroid).