Disjoint Set Calculator: Union-Find Operations Online

Perform Disjoint Set Operations

Specify the total number of elements in your universe (0 to N-1). This input is used for initialization.
For 'Find' (element to find), for 'Union' (first element of set to merge).
Required only for 'Union' operation (second element of set to merge).

Quickly perform Disjoint Set Union (DSU) operations and visualize the results. Our online calculator helps you understand the find and union operations, essential for graph algorithms, network connectivity, and other data structure optimizations. Ideal for students and developers learning about efficient set management.

Formula:

The Disjoint Set Union (DSU) data structure, also known as Union-Find, manages a collection of disjoint sets. Its core operations are:

  • find(x): Determines which set an element x belongs to. It returns the representative (or root) of that set. With path compression, this operation becomes very efficient.
  • union(x, y): Merges the sets containing elements x and y into a single set. This typically uses a heuristic like union by rank or union by size to maintain tree balance, ensuring efficiency.

The state of the DSU is often represented by a parent array, where parent[i] stores the parent of element i.

Computing and Algorithms & Data Structures Tools

AI Token Cost : Estimate & Optimize Your LLM API Spend

Go to Calculator

API Call Cost : Accurately Estimate Your Cloud Expenses

Go to Calculator

API Integration Cost

Go to Calculator

App Development Cost

Go to Calculator

Base64 Decoder: Convert Base64 to Plain Text Online

Go to Calculator

Binary Addition : Sum Binary Numbers Instantly

Go to Calculator