Questions tagged [disjoint-union]

55 questions
0
votes
2 answers

SQL query with AND/OR logical operators

fI have what seems to be a relatively simple AND/OR clause that is giving me a bit of a headache. $query = "SELECT stv.name,stc.tmplvarid,stc.contentid,stv.type,stv.display,stv.display_params,stc.value"; $query .= " FROM ".$tb1." stc LEFT JOIN…
Vecta
  • 2,312
  • 5
  • 28
  • 47
0
votes
1 answer

Getting the maximum and minimum size of disjoint subsets

I am writing code to perform Union-Find on a graph, The first line of input is: n m [n is number of nodes, and m is number of edges] Then m lines follow, indicating which two nodes are connected When I encounter each edge, I perform an union…
user4822631
0
votes
0 answers

Money Matters uVA 11690 gives "Wrong Answer" and "Time Limit Exceeded" after multiple tries

Here is the link to the problem: prob https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2737 Following is my implementation. I tried their sample test case and multiple others and they all give the…
blehadfas1
  • 315
  • 1
  • 5
  • 13
0
votes
1 answer

Connecting disjoint sets in a 2D array

I am trying to generate a random grid with positions that are Traversable and Non-Traversable and ensure that there is a path from one Traversable position to any other Traversable position in one of the 4 directions {Right, Up, Left, Down}.…
hededo
  • 371
  • 2
  • 16
0
votes
1 answer

Disjoint Set DS

I have been studying disjoint set data structures. I've a query that while using union by rank & path compression together, if we skip using union by rank & assign precedence(parent) without any ranks comparison(of ranks of roots/representative…
0
votes
1 answer

Python sum of classes

I want to define a class AorB, such that all A's are AorB's, and all B's are AorB's, and these are all the AorB's. Of course, A and B should be subclasses of AorB. The problem is in AorB.__init__, when I can't convince self it should be something…
Veky
  • 2,646
  • 1
  • 21
  • 30
-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 Set Forest to schedule jobs

How can I use the disjoint set- forests to schedule jobs with penalties, such that the penalties are minimized? We could first arrange the jobs in decreasing order on the basis of their penalties. Each node x of the forest will represent the job…
tanvi
  • 927
  • 5
  • 17
  • 32
-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
4