Skip to main content

Questions tagged [union-find]

A union/find data structure is a data structure used for maintaining a partition of a set.

3 votes
1 answer
173 views

This is my first C++ class, implementing union find. I’ve tested the implementation very shoddily by checking that unifying two points connects them, and that works. I did a first draft in Python and ...
schuelermine's user avatar
1 vote
2 answers
405 views

I'm given a distance and a list of points in a plane, where I have to return a sorted list of the size of each connected component where each edge is shorter or equal to the distance threshold. I've ...
Exercise To The Reader's user avatar
3 votes
1 answer
298 views

I am studying Algorithms by Princeton University. The first week assignment is to simulate percolation by using Java. https://coursera.cs.princeton.edu/algs4/assignments/percolation/specification.php ...
yip's user avatar
  • 135
4 votes
1 answer
180 views

For a final project I used a weighted union-find and decided to implement it in Python. I wrote it to be as general as possible so it's very portable. I do plan on looking into path compression to ...
Gabe Ron's user avatar
  • 143
4 votes
4 answers
795 views

I'm an intermediate-level C++ programmer aiming to write reference-quality code. I hope to learn about any mistakes in this piece of code and blind spots in my understanding of concepts. Notes: The ...
Nayuki's user avatar
  • 1,369
2 votes
1 answer
114 views

The question was on Leetcode 1584. Min Cost to Connect All Points. My answer to this question is: ...
Tangcb's user avatar
  • 21
12 votes
1 answer
1k views

I decided to implement a DisjointSet<T> data structure myself in Rust, with no dependencies except for std, for the ...
naiveai's user avatar
  • 166
4 votes
1 answer
318 views

here below a working implementation that finds the minimal distance between k(set =4 below) clusters in a graph. I have doubts mainly on the implementation of the ...
Giogre's user avatar
  • 515
2 votes
2 answers
142 views

I am studying algorithms and I did this "Union Find Like" algorithm. I have one array of objects with a reference and I make the union pointing to the same reference instead of have two int[]...
Juru's user avatar
  • 29
0 votes
2 answers
1k views

I tried to implement union find (disjoint set data structure) algorithm in C++. There I used unordered_map data structure. Is there a better way of doing this using any other data structure. While ...
rusiru thushara's user avatar
3 votes
2 answers
112 views

I've created an integer index based union find implementation in C#, and am looking for some feedback. Unit tests have been written with NUnit. Some questions I am considering: Can the implementation ...
MiniWalrus's user avatar
5 votes
3 answers
4k views

I am given a short int. I need to print the bits of it into two bytes. My code is as follows: ...
Nehal Samee's user avatar
3 votes
1 answer
307 views

This code computes the Minimum Spanning Tree of a given graph using Kruskals Algorithm. It works successfully and I have provided test cases within the code. I would like feedback on code efficiency ...
justanothertechdude's user avatar
3 votes
1 answer
162 views

My code detects if a cycle is present in a graph using Union find algorithm with Weighted tree analysis and path compression. It works and I have included test cases. ...
justanothertechdude's user avatar
2 votes
1 answer
209 views

I came up with the following code by following Prof. Sedgewick's lecture on Coursera. Please review this code and let me know if there is anything that I got wrong in implementing Kruskal's ...
bdsg4D's user avatar
  • 131

15 30 50 per page