Answer:
Explanation: UNION(x, y):
Find the roots of the trees that contain x and y. Let these roots be rootX and rootY, respectively.
If rootX and rootY are the same, return (already in the same set).
Compare the ranks of rootX and rootY.
If rootX has a higher rank than rootY, set rootY as a child of rootX.
If rootY has a higher rank than rootX, set rootX as a child of rootY.
If the ranks of rootX and rootY are the same, set rootY as a child of rootX and increase the rank of rootX by 1.
MAKE-SET(x):
Create a new set with x as its only element and assign it a rank of 0.
Set the parent of x to be x itself (i.e., x is the root of the set).
Note: The rank of a set represents the height of its tree in the disjoint-set forest, and the path-compression heuristics is a technique used to optimize the performance of the union and find operations by flattening the structure of the trees in the disjoint-set forest.