Consider the properties to perform union of the sets.
Property 1: For , Create a root node with rank K by merging the two trees with roots of rank .
Property 2: Any root node of rank K has at least nodes in its tree.
Property 3: If there are n elements overall, there can be at most nodes of rank .
Consider the singleton sets . Represent the singleton sets as the nodes with the rank 0 .

Perform ,by using properties.

The node with the lowest number points to the highest number, and the number of nodes or subtrees are represented as degree.
Perform as follows,

The node 4 has two sub nodes, the degree of the node is updated as 2.
Perform

By the property 1, node 6 points to the node7 and the degree of the 7 is updated to 2 and the degree of 8 is updated to 3.
Perform

By the property 1, the node 4 points to 5 and the degrees of node 6,7, and 8 are updated accordingly. The tree has now has the root with larger degree, by applying properties 1 and 2 , merge the tree as follows.

Perform ,
Disassociate the nodes with the highest degrees and make them pointed to the higher numbered root as follows.

Therefore, the state of disjoint set data structure is found by the path compression method