2020-06-22 01:45:24 +00:00
---
id: dsu
title: "Disjoint Set Union"
2020-06-22 16:31:47 +00:00
author: Benjamin Qi, Michael Cao
2020-06-22 14:26:06 +00:00
prerequisites:
2020-06-22 20:51:12 +00:00
- Silver - Depth First Search
2020-06-22 19:59:16 +00:00
description: The Disjoint Set Union (DSU) data structure allows you to add edges to an initially empty graph and test whether two vertices of the graph are connected.
2020-06-22 01:45:24 +00:00
---
## Tutorial
2020-06-23 01:00:35 +00:00
- CPH 15.2
- [PAPS 11.1 ](https://www.csc.kth.se/~jsannemo/slask/main.pdf )
2020-06-22 16:31:47 +00:00
- Chapter 10.6 of "An Introduction to the US Computing Olympiad"
2020-06-22 01:45:24 +00:00
- [CSAcademy Disjoint-Set ](https://csacademy.com/lesson/disjoint_data_sets )
- [Topcoder Union Find ](https://www.topcoder.com/community/data-science/data-science-tutorials/disjoint-set-data-structures/ )
- [CPC.3 ](https://github.com/SuprDewd/T-414-AFLV/tree/master/03_data_structures )
- DSU Complexity Proofs (optional of course)
- [log\*n ](https://en.wikipedia.org/wiki/Proof_of_O(log*n )\_time_complexity\_of_union%E2%80%93find)
- [a(m,n) ](https://dl.acm.org/doi/pdf/10.1145/321879.321884 )
2020-06-22 14:26:06 +00:00
with rollback: https://codeforces.com/contest/1140/problem/F
2020-06-22 01:45:24 +00:00
## Problems
- [Mootube ](http://www.usaco.org/index.php?page=viewproblem2&cpid=789 )
2020-06-22 14:26:06 +00:00
- same as [CSES Road Construction ](https://cses.fi/problemset/task/1676 )
2020-06-22 01:45:24 +00:00
- [Closing the Farm ](http://www.usaco.org/index.php?page=viewproblem2&cpid=646 )
- [CSES Network Breakdown ](https://cses.fi/problemset/task/1677 )
- [Favorite Colors ](http://www.usaco.org/index.php?page=viewproblem2&cpid=1042 )
2020-06-22 16:31:47 +00:00
- fairly tricky