fully implemented a vanilla Quick Union Union Find algorithm