Graph Theory37 sections · 1633 units
Open in Course

LeetCode 310 Minimum Height Trees - Strategy

Topological peeling algorithm

You could find the Diameter and pick the middle, but there is another intuitive approach: Topological Peeling. Start from the leaves (nodes with degree 11) and peel them off layer by layer. After each layer is removed, new leaves appear. Keep peeling until only 11 or 22 nodes remain. These are the centers. Why?

Because the centers are the nodes furthest from all leaves. Peeling removes the outer layers, leaving the core.