Questions tagged [disjoint-sets]

Anything related to disjoint sets, i.e. mathematical sets that have no element in common.

Anything related to disjoint sets, i.e. mathematical sets that have no element in common.

194 questions
0
votes
0 answers

Disjoint Sets with Linked List, C++ - Cormen

This is my implementation of Disjoint Sets according with Cormen (Introduction to Algorithms - 2nd Ed. chapter 21). I'm having problem when deleting objects (the "~DisjointSet" destructor). This occurs because the registers of "std::vector sets;"…
lopes
  • 549
  • 5
  • 13
0
votes
1 answer

How to store each set in a disjoint-set forest?

Trying to code this up myself in Java... I have created a GraphNode class to represent nodes that have a pointer to their parent. I have also created a DisjointSet class that includes a MakeSet method that creates a GraphNode object and has its…
user1956609
  • 2,132
  • 5
  • 27
  • 43
0
votes
1 answer

Minimum number of char substitutions to get a palindrome

I would like to solve this problem from TopCoder, in which a String is given and in each step you have to replace all occurrences of an character (of your choice) with another character (of your choice), so that at the end after all steps you get a…
V G
  • 18,822
  • 6
  • 51
  • 89
0
votes
1 answer

Heuristics by weight and path compression

Generally heuristics by rank and path compression are used to achieve fast disjoint-set data structure operations. Somehow, I find heuristics by weight and path compression more sensible to me. Does the following implementation achieve the same…
sudeepdino008
  • 3,194
  • 5
  • 39
  • 73
0
votes
3 answers

Splitting data into disjoint sets

I've a matrix (200x3) which i want to split into 3 random chosen disjoint sets. How can i realize it? I tried to do it via sample method but sample method accepts just vectors and output is not really part of my matrix. Thus, it is my matrix: …
Asqan
  • 4,319
  • 11
  • 61
  • 100
0
votes
2 answers

Discrete Maths: Check connectivity of a graph after removing a vertex? Efficient Way?

First: I admit that its a part of programming contest(where nothings on a stake to win or something) I've come to the following conclusion after reading the problem & tried following algorithm. Given Undirected Connected Graph of n vertices, count =…
0
votes
1 answer

Disjoint sets issue

I'm trying to write an implementation of Kruskal's Algorithm using disjoint sets. I think I have it nearly working, but I cannot seem to make a piece of the code work right. The code needs to check to see if a node on the graph is already in the…
gmaster
  • 692
  • 1
  • 10
  • 27
0
votes
1 answer

Implementation of Disjoint Sets and Kruskal's Algorithm(and other data structures) in OpenCL

I want to implement Disjoint set Data Structures and Kruskal's algorithm in OpenCL. I have implemented some codes in OpenCL, but don't know how to get started with Data Structures in OpenCL. Djkstra's algorithm given in the book by Aftab Munshi is…
shunya
  • 533
  • 1
  • 5
  • 16
-1
votes
2 answers

Leetcode Number of Province not passing edge case last few edge case

I try using the Union find method for this question but not passing this case, could somebody may be give me an insight to why that is? find() : for find method there is path compression union() : for union there is union by rank Question link So…
Intern
  • 39
  • 1
  • 5
-1
votes
1 answer

disjoint Pattern-Matching

i have a question about disjoint Matching pattern. The matching pattern is disjoint when each case does not step on other cases. def func(list: List[Int]): Int = list match { case Nil => 0 case x::t if (x < func(t)) => x case x::t =>…
-1
votes
1 answer

Python OOP Disjoint Set Performance

I built a disjoint-set data structure for use with Kruskal's MST algorithm. I need to load and then union a graph with 200k interconnected nodes and I think my data structure implementation is a bottleneck. Do you have an suggestions for how to…
-1
votes
2 answers

Disjoint Set ADT Implementation in C++

I have problem in implementing a disjoint set ADT in C++ due to the fact that our teacher only explained the union and find operations. I fully understand the concepts of union and find but I am still confused about how to implement them. Could…
Zia ur Rahman
  • 1,411
  • 4
  • 26
  • 43
-2
votes
1 answer

Disjoint set data structure : track size of each tree

Below is my implementation to keep track of the size of each tree in the disjoint set forest. Can you please tell me what is wrong with it ? I am trying to solve UVa problem…
-3
votes
1 answer

How to solve this Union-Find disjoint set problem?

I am stuck on this problem: https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=1099 Currently, I have sets, where each element in the set are friends. However, I don't know how to proceed with the enemies. Could…
1 2 3
12
13