Graph Theory37 sections · 1633 units
Open in Course

Naive Merging

(Why it fails)

The obvious approach: pick one child's set as the base, then insert all elements from other children's sets one by one. For each child set of size kk, you do kk insertions. If you have sets of sizes s1,s2,.,scs_1, s_2,., s_c, you pay s1+s2+.+scs_1 + s_2 +. + s_c operations per node.

This seems fine per node, but across the whole tree it breaks down. The total cost depends on which set you choose as the base. Choose poorly and you hit quadratic time.