Data Structures19 sections · 729 units
Open in Course

Lessons from Distance Queries

summary

Important lessons:

1.1. Centroid decomposition reduces tree queries to queries about centroid ancestors

2.2. The O(logn)O(\log n) depth bound keeps space and time manageable

3.3. Any path in the tree passes through exactly one lowest common centroid ancestor

4.4. LCA-based distance is simpler for this problem, but centroid decomposition extends to harder variants

When should you use centroid decomposition over LCA? When the problem involves updating nodes or more complex path properties.