In: Computer Science
Redo Exercise 21.2-2 using a disjoint-set forest with union by rank and path compression.
==> after (x1 U x5) is
called, FIND-SET(x1) and FIND-SET(x5) are called first
==> Result o f (x1 U x5)
==> After (x11 U x13) called, FIND-SET(x11) and FIND-SET(x13) is called first
==> Result of (x11 U x13)
==> Similarly the result of (x1 U x10)
==> After calling FIND-SET(x2), the result is as follows and it returns x16
==> After calling
FIND-SET(x9), the result is as follows and it returns x16
Therefore
FIND-SET(x1) and FIND-SET(x9) both returns the set representative, that is x16