Small-to-Large Merging — merge the smaller into the larger

Rooted tree — colors & subtree sets

larger set (destination) smaller set (poured in) active node heavy child / kept finished
Speed 650 ms
moves / adds: 0 budget N·log₂N: 0 step: 0 / 0
Press Step to walk the post-order DFS. We always pour the smaller set into the larger. Watch the move counter stay well under the N·log₂N budget.

Per-node subtree sets

Trace log