Questions tagged [disjoint-sets]

23 questions
10
votes
1 answer

Runtime difference bewteen Union by Rank and Union by Size for union-find

I was studying Union Find, and according to Wikipedia, there are 2 types of union: union by rank and Union by size. My question is, what is the runtime difference between the two (if any)? Intuitively, it feels like Union by size would always be…
timg
  • 254
  • 2
  • 7
4
votes
2 answers

Testing the property of being a union of three disjoint cliques

Design an $\epsilon$-test for the following property in the dense graph model: $G(V,E)$ is a union of three disjoint cliques. I've been sitting for a few hours and I don't have any idea of how to solve this one ... anyone has any ideas / leads? I…
4
votes
1 answer

Question about tidy trees (Union-Find)

The following excerpt is taken from this paper, in page 3. Our new union-find-delete data structure, like most other union-find data structures, maintains the elements of each set in a rooted tree. As elements can now be deleted, not all the nodes…
Shlomiz
  • 119
  • 6
3
votes
0 answers

What's the best non-amortized disjoint set?

In practice, the amortized O(α(n)) data structure is good for every case. But if I want to be pedantic and require each operation to be under a certain time complexity, what's the currently known best complexity, and is it optimal? The normal…
user23013
  • 498
  • 2
  • 13
2
votes
0 answers

Is the Union-Find algorithm really based on trees?

In the Union-Find data structure (also known as the Disjoint-Set data structure), elements of a set have directed edges providing paths to the representative element, or root, of the set. Each set representation is referred to as a tree, with the…
Ellen Spertus
  • 1,592
  • 13
  • 30
2
votes
0 answers

Difficulty in last sentence in proof of "Amortized cost of $\text{Find-Set}$ operation is $O(\alpha(n))$" from CLRS

I was reading the section of Data Structures for Disjoint Sets from the text Introduction to Algorithms by Cormen et. al. I made it through the proof, but I'm not sure I understand the very last sentence (and it seems a little handwavy to me) The…
2
votes
1 answer

Bounding the height of a tree in a variant of disjoint set union

Consider a variant of link-by-size implementation of the Union–Find data structure, in which trees will be linked by the logarithm of the size. Let $\ell_i$ = $⌊\log_2|T_i|⌋$ and, when merging $T_i$ and $T_j$, we use the following rules: • if…
SVMteamsTool
  • 453
  • 2
  • 13
2
votes
1 answer

Make maze connected by removing internal walls

Recently I've stumbled upon a strange graph problem. Here is a brief description. Given $n\times m$ matrix with $2n + 1$ rows such that each row contains $2m + 1$ characters "+", "-", "|", "." First, last row, and first, last column are the…
1
vote
1 answer

How to create a tree of height $lg(n)$ using Union-Find data structure

I'm wondering given a set $A$ of $n$ numbers, is there any procedure that can create a tree of height $lg(n)$ that contain all the elements of $A$ by applying consecutive Union by rank operation in a Union-Find data structure. The Find operation is…
Daniel
  • 341
  • 1
  • 8
1
vote
0 answers

Set cover variation: disjoint covers for all but one element

In the classical set cover problem, we are given the set $U$ of elements $\{1, \dots, n\}$ and a collection $C$ of some subsets such that their union is the whole set. Now, I will introduce the first small twist: instead of searching for one cover,…
1
vote
1 answer

Disjoint Set Constant Time Union Operation

I am following a LeetCode tutorial for Disjoint sets I have trouble understanding why the so called "Quick Find" method needs to take O(n) time. I have implemented an data structure that has an optimised Union operation and it is O(1). // Base class…
Vallerious
  • 115
  • 2
1
vote
0 answers

Algorithm to check if a family contains two disjoint sets

Let $\mathcal F_1$ and $\mathcal F_2$ be a families of subsets of $\{1,\dots, m\}$. Such that $|\mathcal F_1| = n_1$ and $|\mathcal F_2| = n_2$. I would like to check if there is $f_1\in \mathcal F_1$ and $f_2\in \mathcal F_2$ with $f_1\cap f_2 =…
user26358
1
vote
1 answer

Check if two graphs are edge-disjoint

Two undirected graphs $G$ and $H$ on the vertices $1,2,\ldots,n$ are disjoint if the intersection of their edge sets is empty. Assume both $G$ and $H$ are represented by adjacency matrices. Describe an efficient algorithm that decides if…
Benny
  • 71
  • 4
1
vote
2 answers

walk / traverse a disjoint set that has union rank and path compression

I'm studying CLRS section 21.3, which introduces a union rank + path-compressed implementation of disjoint set. The implementations of MAKE-SET, UNION, LINK, and FIND-SET on p 571 of the book all work with nodes themselves, where each node has a…
xdavidliu
  • 888
  • 7
  • 17
1
vote
1 answer

Definition of Disjointness for binary strings

Basically, most of the definition for disjointness are such that $DISJ(A, B) = 1$ if $A \cap B = \emptyset $ and $DISJ(A, B) = 0$ for other case. My confusion is how is $0$'s influence in here. For example, is all-zeros string considered as…
exteral
  • 135
  • 3
1
2