Given, two disjoint sets with roots 1 and 6 respectively which already have their childrens' paths compressed.
I wish to do a union but instead of
this
I want
this
Unable to figure out a way to do this optimally.
DSU I am using is on cp-algorithms
Path compression upon union in DSU
Given, two disjoint sets with roots 1 and 6 respectively which already have their childrens' paths compressed.
I wish to do a union but instead of
I want
Unable to figure out a way to do this optimally.
DSU I am using is on cp-algorithms