Grokking Graph Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content

On this page

Core Operations of Union-Find (Disjoint Set Union - DSU):

Union-Find: A Story of Connections

Naive Implementation of Disjoint Set

  1. Creating Disjoint Sets
  1. Find Operation
  1. Union Operation

Optimizations

  1. Path Compression
  1. Union by Rank

Complexity Analysis

  1. Union by Size

Most Optimized Approach: Combining Path Compression and Union by Rank

Pros and Cons of DSU

Why Choose Union-Find Over BFS/DFS?