Graph Theory37 sections · 1633 units
Open in Course

Why Depth is O(log n)

(Each level halves the size)

When you remove a centroid, each component has at most n/2n/2 nodes. At the next level, components have at most n/4n/4 nodes. Then n/8n/8, and so on. Each level halves the maximum component size. After kk levels, components have at most n/2kn / 2^k nodes.

When this reaches 11, you are done. Solving n/2k=1n / 2^k = 1 gives k=log⁡2nk = \log_2 n, so the depth is logarithmic. So the decomposition tree has O(log⁡n)O(\log n) depth, which bounds the recursion depth. This is why centroid decomposition is efficient.

Space complexity is O(n)O(n) for the data structures used.