What is the role of 'union by rank' in Union-Find?
Union by rank ensures that all trees in the structure are balanced, preventing any tree from becoming too deep and thus making the 'find' operation faster.
Thatâ€™s partially correct. Union by rank helps balance the trees, but it specifically uses the rank to decide which tree should be the root.
Can you explain how rank is used in practice to decide which tree becomes the root during a union?