Graph Theory37 sections · 1633 units
Open in Course

Walkthrough

(Tracing the algorithm)

Tree: 121-2, 232-3, 242-4, 454-5. Five nodes. Root at 11. After DFS, subtree sizes: size[1]=5, size[2]=4, size[3]=1, size[4]=2, size[5]=1. Node 11 has child 22 with size[2]=4 > 5/2=2.5. Move to node 22. From 22, children are 11 (size 11), 33 (size 11), and 44 (size 22).

None exceed 2.52.5. The parent direction would have size 11, also under the threshold. Node 22 is the centroid. Output: 22. The algorithm terminated in two steps, demonstrating the efficiency of walking toward heavy subtrees.