Disjoint-Set/Union-Find Data Structure

Photo by Clay Banks on Unsplash

Note: This post is part of the Data Structures and Algorithm series. To see more posts from this series, click here. The illustrations below are inspired by the Algorithms, Part I course on Coursera. All code examples from this series can be found here.

A disjoint-set (also referred to as a union-find data structure) is a data structure that tracks a set of elements partitioned into a group of…