Graph Theory37 sections · 1633 units
Open in Course

Check Your Understanding

(Path counting logic)

When counting paths of length kk through a centroid, you combine distances from different subtrees. For each node at distance dd from the centroid in subtree A, you count nodes at distance kdk - d in other subtrees. This avoids double-counting paths within the same subtree.

Then you recurse on each subtree separately. Quiz: If the centroid has 33 children with subtrees of sizes 1010, 1515, and 2020, how many times do you recurse after processing the centroid?