Merge elements and watch the components and their roots change.
Union by rank with path compression makes membership tests effectively constant time.
root 0: { 0 }
root 1: { 1 }
root 2: { 2 }
root 3: { 3 }
root 4: { 4 }
root 5: { 5 }
root 6: { 6 }
root 7: { 7 }Eight elements, each in its own component.