A union-find algorithm performs two useful operations a selected data structure:
- Find: Determine which subset a particular element is in. This can be used for determining if two elements are in the same subset.
- Union: join the two giving subsets into a single subset.
Does all the thing listed above with the exception of: before joining to set the algorithm check which subset is the biggest. It will always make the smallest subset be a part of the biggest - the reasons is of course, to maximaise efficiency.