Hi this is my first time posting here,
I have been trying to work out a question for studying but haven't been able to figure it out:
We consider the forest implementation of the disjoint-set abstract data type, with Weighted Union by size and Path Compression. Initially, each element is in a one-node tree.
Starting from the above initial state:
give a (short) sequence of UNION and FIND operations in which the last operation is a UNION that causes a taller tree A to become the subtree of a shorter tree B (ie. the height of A is strictly larger than the height of B).
Show the two trees A and B that the last UNION merges
Hint: You can start from n = 9 elements, each one in a one-node tree.
I'm not sure how that would work since the smaller tree always gets merged with the larger tree because of union by size?
Thanks.