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
1
vote
1 answer

Counting number of members in a disjoint set

I am having a little bit of trouble counting the number of elements in each of my disjoint set members. For example, if someone enters in: Note: first number = source vertex, 2nd number = destination vertex, 3rd number = length 0 2 1 4 8 7 5 8 6 1 2…
user200081
  • 563
  • 2
  • 12
  • 24
1
vote
0 answers

Error mapping Disjoint foreign key

In Mapping Superclass, Subclass Relationship Participation Constraint – Partial Disjoint Constraint - Disjoint Do we have to map a Foreign key from child to parent? If we don't, why not?
1
vote
2 answers

Freebase co-types search timeout

I'm trying to find freebase co-types, that is, given a type you find 'compatible' types: Suppose to start with /people/person, it might be a musician (/music/group_member), but not a music album (/music/album), i don't know if in freebase is there…
Luca Faggianelli
  • 2,032
  • 20
  • 23
0
votes
3 answers

Disjoint-Set forests in Python alternate implementation

I'm implementing a disjoint set system in Python, but I've hit a wall. I'm using a tree implementation for the system and am implementing Find(), Merge() and Create() functions for the system. I am implementing a rank system and path compression…
Christian Benincasa
  • 1,215
  • 1
  • 21
  • 45
0
votes
1 answer

How can I manage memory deallocation in disjoint sets in C++?

I have a set of classes to handle Disjoint sets in my C++ app. I have a hard time implementing the destructors for these classes. Can anyone help me on that? What these basically do is: put nodes' pointers into NodeAddress[], every node is…
Patryk
  • 22,602
  • 44
  • 128
  • 244
0
votes
2 answers

Python: Algorithm Traverse Tree that expands at each node

I have a dictionary with id and multiple values for each ID which are strings. For each value in that for each Id I make a database query and get set results: {111: Run, Jump, swim} {222: Eat, drink} so for each value lets say run I execute a query…
add-semi-colons
  • 18,094
  • 55
  • 145
  • 232
0
votes
1 answer

Find all disjoint subsets of a binray matrix in Pyhton

I have a binary matrix, and I want to find all disjoint subsets that exist in this matrix. To clarify the problem, the matrix is a collection of image masks, masks of irregular shapes, and each disjoint subset of 1s representing a separate mask. In…
Vahid S. Bokharaie
  • 937
  • 1
  • 9
  • 25
0
votes
1 answer

Merging database tables using rank and path compression heuristics

I am having trouble with the following problem in my data structures course. The errors provided by the course are rather ambiguous and I am not able to discern where the bug lies. NOTE: The error message only says "Wrong answer." and the test cases…
0
votes
0 answers

Small to Large merging in c++, ordered_map vs map

I have recently learned about small to large merging. https://usaco.guide/plat/merging?lang=cpp So as an example problem, consider a rooted tree, where each vertex has color. For every vertex v, we are interested in determining the number of unique…
0
votes
0 answers

Disjoint Union of Strings

I have a vector of vector of strings of size == 2 with the following format vector> equations; where equations[i]={"Hi", "I am"}; I want to make a disjoint union of the two strings "Hi" and "I am" for all the values of i. So I tried…
Xiao
  • 21
  • 1
  • 4
0
votes
0 answers

The Value of Friendship : Disjoint set union

I am doing this challenge on HackerRank and I tried to use a mapping between students and sets to represent which group of friends the students belonged to : The list of friends is instantiated with each student having himself as a friend and for…
Paul
  • 314
  • 2
  • 13
0
votes
1 answer

Algorithm for Randomly selecting k elements from n with Some Elements Belonging to Disjoint Pairs

I need to randomly select k elements from a list of n. Let's say that: n = (1,2,3,4,5,6,7,8,9,10) and I want to randomly chose k = 4 elements and arrange them in random order. I am using Perl, so I could easily do this with: @ord = ($o1,$o2,$o3,$o4)…
Dan
  • 165
  • 5
  • 18
0
votes
2 answers

How to check which of multiple given sets are disjoint?

I want to write a method that uses the standard for loop to iterate through a given set of sets, and returns a hashmap that the disjoint sets are added to. I'm aware that the does not work correctly, it's an example of how I've tried to solve this.…
bells
  • 11
  • 4
0
votes
1 answer

Disjoint set data structure in c

I want to implement the structure on the image in C language. But I have a problem because the 2 structures created call each other and therefore pose a problem how can I remedy it? set data structure picture : Imgur link liste set : typedef struct…
Stack Realtek
  • 87
  • 1
  • 6
0
votes
0 answers

Unsolvable maze generator using randomized Kruskal's algorithm

I have a pathfinding game and I want to generate a maze using randomized Kruskal's algorithm. I am using a rank-based disjoint set to detect cycles. Specifically, I am using this implementation. However, it turns out that the mazes could not be…
disguisedtoast
  • 149
  • 1
  • 4
  • 15