-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdisjoint-sets.tex
46 lines (41 loc) · 1.31 KB
/
disjoint-sets.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
\frame{
\frametitle{Disjoint Sets}
\framesubtitle{What?}
\begin{itemize}[<+->]
\item A collection of sets
\item Not necessarily the programming datastructure
\item No element in multiple sets
\item Operations needed:
\begin{itemize}
\item union: merge two sets
\item sameSet: are two elements in the same set
\end {itemize}
\end{itemize}
}
\frame{
\frametitle{Disjoint Sets}
\framesubtitle{Why?}
\begin{itemize}[<+->]
\item A common example: groups of friends
\item $x \sim y \Leftrightarrow x \text{ is a friend of } y$
\item $x \sim y \wedge y \sim z \Rightarrow x \sim z$
\item queries: is $x$ friends with $y$?
\item Can be considered as disjoint sets of people
\item People in the same set are friends
\end{itemize}
}
\frame{
\frametitle{Disjoint Sets}
\framesubtitle{How?}
\begin{itemize}[<+->]
\item A vector of std::sets
\item problems:
\begin{itemize}
\item Complicated
\item Inefficient
\item Fiddling with both merging of sets, and managing the vector
\end{itemize}
\item There must be something better
\item Union-Find!
\end{itemize}
}