Centroid Decomposition on Trees Interactive Visualizer
Centroid Decomposition recursively splits a tree at its centroid (where every remaining component has size <= n/2), producing a Centroid Tree of height O(log n) for path counting and dynamic nearest-node queries.
Study Centroid Decomposition on Trees Explanation · View Multi-Language Code · All Algorithms