Disjoint Set Data Structures Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report A disjoint-set data structure is defined as one that keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets.A union-find algorithm is an algorithm that performs two useful operations on such a data structure:Find: Determine which subset a particular element is in. This can determine if two elements are in the same subset.Union: Join two subsets into a single subset. Here first we have to check if the two subsets belong to the same set. If not, then we cannot perform union. Applications of Disjoint set UnionKruskal's Minimum Spanning TreeJob Sequencing Problem.Cycle Detection Nodes between two vertices in an acyclic Graph Tarjan’s off-line LCAEasy ProblemsMinimum Changes to Make Arrays Identical Check if one string can be converted to anotherSmallest vs Largest Component of a graph after each QueryEquation satisfiability check Earliest Moment When Everyone Become Friends Number of pairs Connecting employees from different companiesMedium and Hard ProblemsNumber of closed islands in given Matrix Minimum difference between components of the Graph after each queryMinimum cost to provide waterMinimum operations for adjacent E and E+1 pairing Email Account Merging Path queries through restricted weighted edges Disjoint Set Introduction Visit Course Disjoint Set Introduction Find and Union Operation on Disjoint Sets Union by Rank (Union-Find Algorithm) Path Compression in Union-Find Algorithm Comment More info K kartik Follow Improve Article Tags : Advanced Data Structure DSA union-find Explore DSA FundamentalsLogic Building Problems 2 min read Analysis of Algorithms 1 min read Data StructuresArray Data Structure 3 min read String in Data Structure 2 min read Hashing in Data Structure 2 min read Linked List Data Structure 2 min read Stack Data Structure 2 min read Queue Data Structure 2 min read Tree Data Structure 2 min read Graph Data Structure 3 min read Trie Data Structure 15+ min read AlgorithmsSearching Algorithms 2 min read Sorting Algorithms 3 min read Introduction to Recursion 14 min read Greedy Algorithms 3 min read Graph Algorithms 3 min read Dynamic Programming or DP 3 min read Bitwise Algorithms 4 min read AdvancedSegment Tree 2 min read Binary Indexed Tree or Fenwick Tree 15 min read Square Root (Sqrt) Decomposition Algorithm 15+ min read Binary Lifting 15+ min read Geometry 2 min read Interview PreparationInterview Corner 3 min read GfG160 3 min read Practice ProblemGeeksforGeeks Practice - Leading Online Coding Platform 6 min read Problem of The Day - Develop the Habit of Coding 5 min read Like