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

minimum collection of vertice disjoint path that covers a given vertice set

Problem Given: A directed graph G A source vertex s in G and a target vertex t in G A set S of vertices of G I want to find a collection of paths from s to t that covers S. Then I want to partition the collection of paths into subcollections of…
1
vote
1 answer

Do we need to update the ranks while path compression in Disjoint set data structure?

I was studying disjoint set data structure. I understand how rank helps us make shallow trees and path compression decrease tree height. I can find the below code in most articles or study materials for path compression. int find(subset[] subsets,…
Vimit Dhawan
  • 597
  • 1
  • 7
  • 25
1
vote
0 answers

Disjoint Set Union

I was solving a problem of Hackerrank in Graphs a particular question https://www.hackerrank.com/challenges/journey-to-the-moon/problem I applied DSU but the answer is wrong even though the code is working for some test cases. void make(int item) { …
Xiao
  • 21
  • 1
  • 4
1
vote
1 answer

Trouble with 'With' statements SQL query

I'm having difficulties writing an SQL query that has multiple WITH statements. I'm quite new to SQL so please bear with me. The context is unimportant but in this case, I'm trying to query a movie database as part of an assignment. This particular…
Mysteryxx3
  • 19
  • 3
1
vote
1 answer

Node Set with disjoint Subset in CPLEX

I am currently trying to implement a directed weighted graph algorithm in CPLEX. For that I need to initialize the following node set P which includes three different disjoint subsets. Node Set P Disjoint Subset 1: {u,v} Disjoint Subset 2:…
A321
  • 17
  • 4
1
vote
3 answers

LinkedHashMap vs LinkedHashSet for retrieving specific elements & retrieving in insertion order

I'm doing a problem that clearly requires usages of Set but I need to retrieve elements from a set in insertion order + retrieve specific elements. But finding the specific element was too slow( I guess O(n) since I have to go through the entire set…
Leon
  • 346
  • 3
  • 15
1
vote
1 answer

ConcurrentDictionary and Disjoint Sets of Keys

There are 3 threads. Each of them works (reads, writes) with its own set of dictionary keys. So keys are mutually exclusive for different threads. There are also multiple threads which only read data. Which of these two approaches is more efficient…
Andrei Sedoi
  • 1,534
  • 1
  • 15
  • 28
1
vote
1 answer

mother vertex using disjoint dataset in directed graph

I had the solution of classical Mother vertex problem using DSU (disjoint data set). I have used path compression. i wanted to know if it is correct or not.I think time complexity O(E log(V)). the solution proceeds as initialise each vertex's…
Suniti Jain
  • 382
  • 2
  • 10
1
vote
2 answers

SQL Check if two columns from two tables are completely disjoint

I have two tables CREATE TABLE A ID INT PRIMARY KEY .... CREATE TABLE B ID INT PRIMARY KEY .... How do I check if A.ID and B.ID are disjoint using postgres. Disjoint meaning there is no value in B.ID that exists in A.ID…
Mistakamikaze
  • 446
  • 3
  • 19
1
vote
1 answer

union find set algorithm return parent[v] = find_set(parent[v]); means

int find_set(int v) { if (v == parent[v]) return v; return parent[v] = find_set(parent[v]); } This is a slice of code of disjoin set algorithm can i ask what is the meaning and purpose of return parent[v] = find_set(parent[v]);? usually the…
1
vote
0 answers

is there disjoint sets data structure in any of javas 3rd party "known" libraries like gueva/apache collections

I've been looking around searching for any "known" Java data structure library(Like google's guava for example) that have disjoint sets data structure... Java's Collections doesn't have it apparently. Implementing it myself is not an option... So…
nadavgam
  • 2,014
  • 5
  • 20
  • 48
1
vote
2 answers

How to properly implement disjoint set data structure for finding spanning forests in Python?

Recently, I was trying to implement the solutions of google kickstater's 2019 programming questions and tried to implement Round E's Cherries Mesh by following the analysis explanation. Here is the link to the question and the…
1
vote
0 answers

Compute the union of intervals Elements of Programming Interviews 13.8 Python

My program needs to output a list of interval objects expressed as a set of disjoint intervals. Assume True implies close ended ie:inclusive and False implied the endpoint is open ended ie: exclusive. For example, consider the example “(176, False,…
user10312001
1
vote
2 answers

How to make a function to know if disjoint set array represent single partition?

Suppose I have disjoint set with array implementation like this. Consider this disjoint set array [0,0,3,3] which represents the following partition:{0,1}{2,3}. As you can see, the array [0,0,3,3] represents 2 partition class, that is, {0,1} and…
1
vote
0 answers

Reduce list of interval(begin & end time) to get maximum no of non-overlapping function that we can attend in a day

I am creating a Java 8 program which gives the maximum number of functions that a person can attend in a day. i.e) A person can be present in only one function at any given time interval. I tried coding to get the solution but was not able to find…
RamkumarSP
  • 55
  • 5