mirror of
https://github.com/janishutz/eth-summaries.git
synced 2025-11-26 02:54:24 +00:00
Restructure files
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
\newpage
|
||||
\subsubsection{Convex hull}
|
||||
\begin{definition}[]{Convex hull}
|
||||
Let $S \subseteq \R^d, d \in \N$. The \textit{convex hull}, $\text{conv}(S)$ of $S$ is the cut of all convex sets that contains $S$, i.e.
|
||||
\begin{align*}
|
||||
\text{conv}(S) := \bigcap_{S\subseteq C \subseteq \R^d} C
|
||||
\end{align*}
|
||||
where $C$ is convex
|
||||
\end{definition}
|
||||
A convex hull is always convex again.
|
||||
|
||||
|
||||
\setcounter{all}{37}
|
||||
\begin{theorem}[]{JarvisWrap}
|
||||
The \verb|JarvisWrap| algorithm can find the convex hull in \tco{nh}, where $h$ is the number of corners of $P$ and $P$ is a set of $n$ points in any position in $\R^2$.
|
||||
\end{theorem}
|
||||
|
||||
|
||||
\begin{algorithm}
|
||||
\caption{JarvisWrap}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{FindNext}{$q$}
|
||||
\State Choose $p_0 \in P\backslash\{q\}$ arbitrarily
|
||||
\State $q_{next} \gets p_0$
|
||||
\For{\textbf{all} $p \in P\backslash \{q, p_0\}$}
|
||||
\If{$p$ is to right of $q q_{next}$}
|
||||
$q_{next} \gets p$ \Comment{$qq_{next}$ is vector from $q$ to $q_{next}$}
|
||||
\EndIf
|
||||
\EndFor
|
||||
\State \Return $q_{next}$
|
||||
\EndProcedure
|
||||
\Procedure{JarvisWrap}{$P$}
|
||||
\State $h \gets 0$
|
||||
\State $p_{now} \gets$ point in $P$ with lowest $x$-coordinate
|
||||
\While{$p_{now} \neq q_0$}
|
||||
\State $q_h \gets p_{now}$
|
||||
\State $p_now \gets$ \Call{FindNext}{$q_h$}
|
||||
\State $h \gets h + 1$
|
||||
\EndWhile
|
||||
\State \Return $(q_0, q_1, \ldots, q_{h - 1})$
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
|
||||
|
||||
\newpage
|
||||
\fhlc{Cyan}{LocalRepair}
|
||||
\begin{algorithm}
|
||||
\caption{LocalRepair}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{LocalRepair}{$p_1, \ldots, p_n$}
|
||||
\State $q_0 \gets q_1$ \Comment{input sorted according to $x$-coordinate}
|
||||
\State $h \gets 0$
|
||||
\For{$i \in \{2, \ldots, n\}$} \Comment{Lower convex hull, left to right}
|
||||
\While{$h > 0$ and $q_h$ is to the left of $q_{h - 1}p_i$} \Comment{$q_{h - 1}p_i$ is a vector}
|
||||
\State $h \gets h - 1$
|
||||
\EndWhile
|
||||
\State $h \gets h + 1$
|
||||
\State $q_h \gets p_i$ \Comment{$(q_0, \ldots, q_h)$ is lower convex hull of $\{p_1, \ldots, p_i\}$}
|
||||
\EndFor
|
||||
\State $h' \gets h$
|
||||
\For{$i \in \{n - 1, \ldots, 1\}$} \Comment{Upper convex hull, right to left}
|
||||
\While{$h > h'$ and $q_h$ is to the left of $q_{h - 1}p_i$} \Comment{$q_{h - 1}p_i$ is a vector}
|
||||
\State $h \gets h - 1$
|
||||
\EndWhile
|
||||
\State $h \gets h + 1$
|
||||
\State $q_h \gets p_i$
|
||||
\EndFor
|
||||
\State \Return $(q_0, \ldots, q_{h - 1})$ \Comment{The corners of the convex hull, counterclockwise}
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
|
||||
\setcounter{all}{42}
|
||||
\begin{theorem}[]{LocalRepair}
|
||||
The \verb|LocalRepair| algorithm can find the convex hull of a (in respect to the $x$-coordinate of each point) sorted set $P$ of $n$ points in $\R^2$ in \tco{n}.
|
||||
\end{theorem}
|
||||
|
||||
The idea of the \verb|LocalRepair| algorithm is to repeatedly correct mistakes in the originally randomly chosen polygon.
|
||||
The improvement steps add edges to the polygon such that eventually all vertices lay withing the smallest enclosing circle of the polygon.
|
||||
@@ -0,0 +1,104 @@
|
||||
\newpage
|
||||
\subsection{Geometric Algorithms}
|
||||
|
||||
\subsubsection{Smallest enclosing circle}
|
||||
\newcommand{\cplane}{C^\text{\textbullet}}
|
||||
Given a set $P$ of $n$ points in a plane, we want to find a circle $C(P)$ such that $C(P)$ encloses all points of $P$ and whose \textit{radius} is minimal (SEC).
|
||||
For a circle $C$ we use $\cplane$ for the circular plane enclosed by $C$, including $C$ and we also allow the points in $P$ to lay on $C(P)$.
|
||||
\begin{lemma}[]{Existence of distinct SEC}
|
||||
For each (finite) set of points $P$ in $\R^2$ there exists a distinct smallest enclosing circle $C(P)$
|
||||
\end{lemma}
|
||||
|
||||
The below lemma forms the basis of our algorithm
|
||||
\begin{lemma}[]{Subset of set of points}
|
||||
For each (finite) set of points $P$ in $\R^2$ with $|P| \geq 3$ there exists a subset $Q \subseteq P$ such that $|Q| = 3$ and $C(Q) = C(P)$
|
||||
\end{lemma}
|
||||
|
||||
\begin{algorithm}
|
||||
\caption{Smallest Enclosing Circle $C(P)$}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{CompleteEnumeration}{$P$}
|
||||
\For{\textbf{all} $Q \subseteq P$ with $|Q| = 3$}
|
||||
\State determine $C(Q)$
|
||||
\If{$P \subseteq \cplane(Q)$}
|
||||
\State \Return $C(Q)$
|
||||
\EndIf
|
||||
\EndFor
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
The above algorithm has time complexity \tco{n^4}, which is due to having to check at most ${n \choose 3}$ sets $Q$, for which we can determine $C(Q)$ in constant time, since $|Q| = 3$. We then have to check for each point in $P$ if it is contained in $\cplane(Q)$, which we can do in \tco{n}, since we can check for each point in constant time.
|
||||
|
||||
This is quite inefficient and using a randomized algorithm, we can achieve \tco{n \ln(n)}
|
||||
|
||||
\begin{algorithm}
|
||||
\caption{Smallest Enclosing Circle $C(P)$ randomized}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{CompleteEnumerationRandomized}{$P$}
|
||||
\While{\textit{always}}
|
||||
\State select $Q \subseteq P$ with $|Q| = 11$ uniformly randomly
|
||||
\State determine $C(Q)$
|
||||
\If{$P \subseteq \cplane(Q)$}
|
||||
\State \Return $C(Q)$
|
||||
\EndIf
|
||||
\State double all points in $P$ outside $C(Q)$
|
||||
\EndWhile
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
To implement this algorithm, we also need the doubling function: We initialize an array \verb|num| to length $n$ to $1$. \verb|num[i]| now contains the number of copies of the $i$-th point. If the point lays outside $C(Q)$, we can simply set \verb|num[i] = 2 * num[i]|
|
||||
|
||||
\newpage
|
||||
To select $11$ points uniformly randomly in \tco{n}, consider
|
||||
\begin{lemma}[]{Uniformly random $Q$}
|
||||
Let $n_1, \ldots, n_t \in \N$ and $N := \sum_{i = 1}^{t} n_i$. We generate $X \in \{1, \ldots, t\}$ randomly as seen in Algorithm \ref{alg:t-uniformly-random-numbers}
|
||||
|
||||
Then we have $\Pr[X = i] = \frac{n_i}{N}$ for all $i = 1, \ldots, t$
|
||||
\end{lemma}
|
||||
|
||||
\begin{algorithm}
|
||||
\caption{Choose uniformly random number}\label{alg:t-uniformly-random-numbers}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{ChooseUniformlyRandom}{$t$}
|
||||
\State \Call{UniformInt}{$1, N$}
|
||||
\State $x \gets 1$
|
||||
\While{$\sum_{i = 1}^{x} n_i < k$}
|
||||
\State $x \gets x + 1$
|
||||
\EndWhile
|
||||
\State \Return $x$
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
|
||||
\begin{lemma}[]{Uniformly random $Q$}
|
||||
Let $P$ be a set of $n$ not necessarily different points and for $r \in \N$ let $R$ be uniformly randomly chosen from ${P \choose r}$. Then, the expected number of points of $P$ that are outside $C(R)$ is at most $3 \frac{n - r}{r + 1} \leq 3\frac{n}{r + 1}$
|
||||
\end{lemma}
|
||||
|
||||
\begin{theorem}[]{Correctness of \textsc{CompleteEnumerationRandomized}}
|
||||
The algorithm \textsc{CompleteEnumerationRandomized} computes the smallest enclosing circle of $P$ in time \tco{n \log(n)}
|
||||
\end{theorem}
|
||||
|
||||
|
||||
\fhlc{Cyan}{Sampling Lemma}
|
||||
\begin{definition}[]{Sampling Lemma helpers}
|
||||
Given a finite set $S$, $n := |S|$ and $\phi$ be an arbitrary function on $2^S$ in an arbitrary range. We define
|
||||
\begin{align*}
|
||||
V(R) = V_{\phi}(R) & := \{ s \in S \divides \phi(R) \cup \{s\} \neq \phi(R) \} \\
|
||||
X(R) = X_{\phi}(R) & := \{ s \in S \divides \phi(R) \backslash \{s\} \neq \phi(R) \}
|
||||
\end{align*}
|
||||
We call elements in $V(R)$ \textit{violators of} $R$ and elements in $X(R)$ we \textit{call external in} $R$
|
||||
\end{definition}
|
||||
|
||||
The sampling lemma connects the expected number of violating elements to the number of external elements.
|
||||
\begin{lemma}[]{Sampling Lemma}
|
||||
Let $k \in \N, 0 \leq k \leq n$. We set $v_k := \E[|V(R)|]$ and $x_k := \E[|X(R)|]$ where $R$ is a subset of $S$ of cardinality $k$, uniformly randomly selected from ${s \choose k}$. Then we have for $r \in \N, 0 \leq r <n$
|
||||
\begin{align*}
|
||||
\frac{v_r}{n - r} = \frac{x_{r + 1}}{r + 1}
|
||||
\end{align*}
|
||||
\end{lemma}
|
||||
|
||||
\begin{corollary}[]{Expected numbers / ranks}
|
||||
If we choose $r$ elements $R$ from a set $A$ of $n$ numbers randomly, the expected rank of the minimum of $R$ in $A$ is exactly $\frac{n - r}{r + 1} + 1 = \frac{n + 1}{r + 1}$.
|
||||
|
||||
If we choose $r$ points $R$ of a set $P$ of $n$ points in a plane randomly, the expected number of points of $P$ that are outside $C(R)$ is at most $3 \frac{n - r}{r + 1}$
|
||||
\end{corollary}
|
||||
Reference in New Issue
Block a user