AI engineering glossary · Data structures algorithms

What is DSU (union-find)?

Union-find (also called disjoint set union, DSU): A structure that tracks a partition of items into groups and supports two operations: find which group an item belongs to, and union two groups. With path compression and union by rank, each operation takes almost constant time.

Level: advancedTopic: Data structures algorithms

Union-find: an example

Grouping friends into circles: after union(Ravi, Meena) and union(Meena, Sana), find gives the same group for Ravi and Sana.

Related terms

More Data structures algorithms terms

Where you learn it

Union-find is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.