This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
usaco-guide/content/5_Gold/DSU.mdx

51 lines
2 KiB
Text
Raw Normal View History

2020-06-25 01:38:05 +00:00
---
id: dsu
title: "Disjoint Set Union"
author: Benjamin Qi, Michael Cao
prerequisites:
- Silver - Depth First Search
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-26 18:00:32 +00:00
frequency: 3
2020-06-25 01:38:05 +00:00
---
import { Problem } from "../models";
export const metadata = {
problems: {
sample: [
2020-07-03 20:29:32 +00:00
new Problem("YS", "Union Find", "unionfind", "Intro|Easy", false, []),
2020-06-25 01:38:05 +00:00
],
general: [
2020-07-03 20:29:32 +00:00
new Problem("Gold", "Closing the Farm", "646", "Easy", false, [], "Simulate process in reverse and maintain the # of connected components. Similar to [CSES Network Breakdown](https://cses.fi/problemset/task/1677)"),
new Problem("Gold", "Mootube", "789", "Normal", false, [], "Answer queries in decreasing order of $k$. Maintain size of each connected component. Same as [CSES Road Construction](https://cses.fi/problemset/task/1676)"),
2020-06-25 01:38:05 +00:00
],
}
};
<problems-list problems={metadata.problems.sample} />
2020-07-06 18:14:41 +00:00
## Resources
2020-06-25 01:38:05 +00:00
2020-06-27 00:33:06 +00:00
<resources>
2020-07-03 20:29:32 +00:00
<resource source="CSA" title="Disjoint Data Sets" url="disjoint_data_sets" starred>both optimizations, diagrams</resource>
<resource source="CPH" title="15.2 - Union-Find">small to large, diagrams</resource>
<resource source="IUSACO" title="10.6 - Disjoint-Set Data Structure">path compression, diagrams</resource>
<resource source="PAPS" title="11.1 - Disjoint Sets">both optimizations, no diagrams</resource>
<resource source="TC" title="Disjoint Set Data Structures" url="disjoint-set-data-structures">diagrams</resource>
2020-06-27 00:33:06 +00:00
<resource source="CPC" title="3 - Data Structures" url="03_data_structures"></resource>
</resources>
2020-06-25 01:38:05 +00:00
2020-07-03 20:29:32 +00:00
Note: You may prefer to use this in place of DFS for computing connected components.
2020-06-25 01:38:05 +00:00
<optional-content title="DSU Complexity Proofs">
- [$\log^* n$](https://en.wikipedia.org/wiki/Proof_of_O(log*n)\_time_complexity\_of_union%E2%80%93find)
- [$\alpha (m,n)$](https://dl.acm.org/doi/pdf/10.1145/321879.321884)
</optional-content>
2020-06-27 03:07:31 +00:00
2020-06-25 04:00:28 +00:00
## Problems
<problems-list problems={metadata.problems.general} />