Open In App

DSU Full Form

Last Updated : 21 Aug, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

DSU Full Form

The term DSU stands for Disjoint Set Union, in the context of Computer Science.

What is DSU?

A data structure that stores non overlapping or disjoint subset of elements is called disjoint set data structure.
Condition for two sets to be disjoint: Two sets are called disjoint sets if they don’t have any element in common, the intersection of sets is a null set.

Why is Disjoint Set Data Structure known as Disjoint Set Union or DSU?

Disjoint Set Data Structures are often called Disjoint Set Union or DSU because of their two main operations:

  • Find
  • Union

It means that if we are given several elements, each of which is a separate set, a Disjoint Set Data Structure will have an operation to combine any two sets (UNION), and it will be able to tell in which set a specific element is (DISJOINT SET).

As a combination of the above operations, Disjoint Set Data Structures are also called as Disjoint Set Union or DSU.

Basic Operations in DSU

Thus the basic implementation of the DSU data structure consists of only three operations:

  • Creation of Disjoint Sets [make_set(v)] – creates a new set consisting of the new element v
  • Union of Sets [union_sets(a, b)] – merges the two specified sets (the set in which the element a is located, and the set in which the element b is located)
  • Find in Disjoint Sets [find_set(v)] – returns the representative (also called leader) of the set that contains the element ‘v’. This representative is an element of its corresponding set. It is selected in each set by the data structure itself (and can change over time, namely after union_sets calls). This representative can be used to check if two elements are part of the same set or not. ‘a‘ and ‘b‘ are exactly in the same set, if find_set(a) == find_set(b). Otherwise they are in different sets.

Time Complexity of Disjoint Set Data Structure or DSU

The main advantage of using DSU is that it allows the above operations in constant time, i.e. O(1) on average.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads