I have a list of sets called groups. groups[i] is a set of labels (integers) that are part of the same group as i. For example, indicates that ...
I have a list of sets called groups. groups[i] is a set of labels (integers) that are part of the same group as i. For example, indicates that ...
I need help to write a function that: takes as input set of tuples returns the number of tuples that has unique numbers Example 1: The e ...
My program is putting out garbage values when asked to print union of two sets. Can someone assist in this case. The unique elements of the second arr ...
When it comes to finding connected components in a graph we can use DFS or DSU. Does there exist an algorithm which is stable to a changing graph, whe ...
I have the following algorithm for detecting a cycle in an undirected graph with a set E of n edges : my question is can I implement the union-find ...
I was asked below question in google interview but could not answer it. I did google search but could not find any correct solution for this problem. ...
The problem: Put the numbers from 1 to M into M columns. At the beginning column i contains only number i. Then, perform N queries of two possible ty ...
I am solving a problem on LeetCode: Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You ...
I have implemented a Disjoint Set Union in C++ for a Kattis problem. However, my solution is inefficient, as I get TLA (Time Limit Exceeded) for the f ...
I am learning union-find and to understand it better, I have written a small program: #include <iostream> #include <vector> #include < ...
I am solving a question on LeetCode.com called Number of Islands: Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0' ...
I want to import this UnionFind- class to my IntelliJ project. But I get a Maven error I do not understand. When I try and type import org.jgrapht.alg ...
The question was on Leetcode 1584. Min Cost to Connect All Points. My answer to this question is: My answer can pass all the test cases but the spe ...
I have two implementations of union-find: one that I've come up on my own (it works) and another that is based on the textbook explanation (surprising ...
What I have: an equivalence relation on the set {1,...,n}, given as the full list of equivalent pairs (a,b) (this is already transitive; no need to co ...
How does these two functions work ? The time complexity of the function find is O(log n) assuming that the length of each chain is O(log n). In this ...
I am quite new to Coq, but for my project I have to use a union-find data structure in Coq. Are there any implementations of the union-find (disjoint ...
Here is the question: exmaple: Output: Groups are formed as: [1,2,3][4][5]. Maximum collection is 56 (collected by volunteer 1, 2, and 3) ...
I used the percolation class from the algs4.jar library, where you can simulate a whole labyrinth and see where the leaks are. I want to show the leak ...
The question in short: does union by rank work only in some circumstance? For example, the input is: (1, 2), (3,4), (3,5), after we run a disjoint-se ...