blatt 8
This commit is contained in:
parent
5db260ed19
commit
47a5b2aa8c
12 changed files with 334 additions and 0 deletions
BIN
übung_8/agt26-blatt08.pdf
Normal file
BIN
übung_8/agt26-blatt08.pdf
Normal file
Binary file not shown.
BIN
übung_8/agt_übung_8.pdf
Normal file
BIN
übung_8/agt_übung_8.pdf
Normal file
Binary file not shown.
18
übung_8/agt_übung_8.tex
Normal file
18
übung_8/agt_übung_8.tex
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
\documentclass[parskip=half]{ngexrcs}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{subcaption}
|
||||
\setkeys{Gin}{pagebox=artbox, width=0.8\textwidth}
|
||||
|
||||
\subject{Algorithmische Graphentheorie}
|
||||
\title{8. Übungsblatt}
|
||||
\author{Jasper Gude \and Pia Röttgers}
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
\points[2em]{20}
|
||||
|
||||
\input{aufgabe_1.tex}
|
||||
\input{aufgabe_2.tex}
|
||||
\input{aufgabe_3.tex}
|
||||
|
||||
\end{document}
|
||||
23
übung_8/aufgabe_1.tex
Normal file
23
übung_8/aufgabe_1.tex
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
\section{Kleinste Schnitte}
|
||||
\begin{tasks}
|
||||
\item
|
||||
Siehe \autoref{fig:1a}.
|
||||
\points{2}
|
||||
|
||||
\begin{figure}
|
||||
\centering
|
||||
\includegraphics[page=1, width=0.5\textwidth]{figures.pdf}
|
||||
\caption{Gegenbeispiel; Minimaler Schnitt $\tup{S, T}$ und nicht minimaler Schnitt $\tup{\set{v}, V \setminus \set{v}}$ in rot.}
|
||||
\label{fig:1a}
|
||||
|
||||
\end{figure}
|
||||
|
||||
\item
|
||||
Die Wahrscheinlichkeit, dass \alg*{Contract} in keiner Iteration
|
||||
eine Kante aus $C = \set{uv \in E \mid u \in S, v \in T}$ mit minimalem Schnitt $\tup{S, T}$ kontrahiert, also immer die falschen Knoten auswählt,
|
||||
ist laut Vorlesung $\frac{2}{n(n-1)}$. Das heißt die Zahl der
|
||||
richtigen Knoten wächst quadratisch, da die Wahrscheinlichkeit quadratisch
|
||||
abnimmt.
|
||||
\points{3}
|
||||
|
||||
\end{tasks}
|
||||
25
übung_8/aufgabe_2.tex
Normal file
25
übung_8/aufgabe_2.tex
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
\section{Implementierung von \textsc{Contract}}
|
||||
\begin{enumerate}
|
||||
\item $G$ nach $H$ kopieren. \hfill $\Oh(1)$
|
||||
\item Wenn $\abs{V_H} \leq 2$, dann ist die Zerlegung $\tup{S, T}$ von $G$,
|
||||
die den beiden letzen Knoten in $H$ entspricht, das Ergebnis.
|
||||
\label{step2}
|
||||
\item Wähle eine Zufallszahl $z$ im Intervall $\interval{1; \abs{V_H}}$. \hfill $\Oh(1)$
|
||||
\item Nimm den Knoten $a = V_H[z]$ und wähle eine Zufallszahl $z'$ im Intervall $\interval{1, \abs{Adj[a]}}$.
|
||||
|
||||
Nimm den Knoten $b = Adj_{z'}[a]$. \hfill $\Oh(1)$
|
||||
\item Bestimme für jeden zu $a$ oder $b$ adjazenten Knoten $c_i$ die Anzahl der Kanten
|
||||
zwischen $c_i$ und $a$ oder $b$. \hfill $\Oh(V_H) = \Oh(n)$.
|
||||
\item Kontrahiere die Kante $ab$. Lösche dazu die Knoten $a, b$ sowie alle zu $a$ oder $b$ inzidenten Kanten. Da Mehrfachkanten als Zahl implementiert sind, sind
|
||||
nur maximal 2 Einträge pro $c_i$ zu löschen. \hfill $\Oh(n)$
|
||||
|
||||
Füge einen neuen Knoten $d$ ein. Füge für jeden Knoten $c_i$ die vorher bestimmte Anzahl
|
||||
an Kanten zwischen $c_i$ und $a$ oder $b$ als Kanten zwischen $c_i$ und $d$ ein.
|
||||
\hfill $\Oh(n)$
|
||||
\item Gehe zurück zu \autoref{step2}
|
||||
\end{enumerate}
|
||||
|
||||
Da der Knoten $a$ durch eine gleichverteilte Zufallszahl $z$ ausgewählt wird und der
|
||||
Knoten $b$ ebenfalls gleichverteilt ausgewählt wird, ist die Kante $ab$ ebenfalls
|
||||
gleichverteilt ausgewählt.
|
||||
\points{6}
|
||||
0
übung_8/aufgabe_3.tex
Normal file
0
übung_8/aufgabe_3.tex
Normal file
38
übung_8/aufgabe_4.tex
Normal file
38
übung_8/aufgabe_4.tex
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
\section{Längste Wege}
|
||||
\begin{tasks}
|
||||
\item
|
||||
Da $s, t$ in $G'$ adjazent zu jedem Knoten in $G$ ist, können wir
|
||||
einen einfachen $s$-$t$-Weg der Länge $k+2$ erzeugen, indem wir
|
||||
einen einfachen Weg der Länge $k$ in $G$ nehmen, $s$ an das eine Ende und $t$ an das andere Ende hängen.
|
||||
|
||||
Umgekehrt kann man aus einem einfachen $s$-$t$-Weg der Länge $k$
|
||||
in $G'$ einen einfachen Weg der Länge $k-2$ in $G$ konstruieren,
|
||||
indem wir $s$ und $t$ entfernen.
|
||||
\points{2}
|
||||
|
||||
\item
|
||||
Ein Hamiltonweg ist ein Weg der alle Knoten in $G$ beinhaltet
|
||||
und somit Länge $n-1$ besitzt.
|
||||
|
||||
Wie wir oben gezeigt haben, kann ein $s$-$t$-Weg der Länge $n+1$
|
||||
in $G'$ leicht in einen Weg der Länge $n-1$ in $G$ umgewandelt
|
||||
werden. Das heißt, dass wir einen Hamiltonweg in $G$ finden,
|
||||
wenn wir einen $s$-$t$-Weg finden.
|
||||
|
||||
Umgekehrt können wir einen Hamiltonweg leicht in einen $s$-$t$-Weg
|
||||
umwandeln, also finden wir einen $s$-$t$-Weg wenn wir einen
|
||||
Hamiltonweg finden.
|
||||
|
||||
Also finden wir einen Hamiltonweg genau dann, wenn wir einen
|
||||
$s$-$t$-Weg finden.
|
||||
\points{1}
|
||||
|
||||
\item
|
||||
Da wir Hamiltonweg auf \algt{Längster $s$-$t$-Weg} reduziert
|
||||
haben, muss also \algt{Längster $s$-$t$-Weg} $\NPe$-schwer sein, denn
|
||||
wenn es in $\Pe$ liegen würde, könnten wir auch Hamiltonweg in
|
||||
polynomieller Zeit lösen. Da wir nicht von $\Pe = \NPe$ ausgehen,
|
||||
ist das nicht möglich.
|
||||
\points{2}
|
||||
|
||||
\end{tasks}
|
||||
BIN
übung_8/figures.pdf
Normal file
BIN
übung_8/figures.pdf
Normal file
Binary file not shown.
71
übung_8/ngexrcs.cls
Normal file
71
übung_8/ngexrcs.cls
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
% vim: set filetype:tex
|
||||
|
||||
% Identification %
|
||||
\NeedsTeXFormat{LaTeX2e}
|
||||
\ProvidesClass{ngexrcs}[2021/12/21 ADS Exercise class]
|
||||
|
||||
% Handle options %
|
||||
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrartcl}}
|
||||
\ProcessOptions\relax
|
||||
|
||||
% More declarations %
|
||||
\LoadClass{scrartcl}
|
||||
|
||||
\KOMAoptions{mpinclude=true}
|
||||
\recalctypearea
|
||||
|
||||
\RequirePackage{ngutils}
|
||||
|
||||
% define fonts
|
||||
\RequirePackage{fontspec}
|
||||
\RequirePackage[math-style=upright]{unicode-math}
|
||||
\setmainfont{TeX Gyre Pagella}
|
||||
\setsansfont{TeX Gyre Heros}
|
||||
\setmonofont{TeX Gyre Cursor}
|
||||
\setmathfont{Euler Math}
|
||||
|
||||
\setlength{\marginparwidth}{1.5\marginparwidth}
|
||||
\setlength{\fboxrule}{\heavyrulewidth}
|
||||
|
||||
% Use sansfont for all title elements
|
||||
\addtokomafont{titlehead}{\sffamily}
|
||||
\addtokomafont{subject}{\sffamily}
|
||||
\addtokomafont{title}{\sffamily}
|
||||
\addtokomafont{subtitle}{\sffamily}
|
||||
\addtokomafont{author}{\sffamily}
|
||||
\addtokomafont{date}{\sffamily}
|
||||
\addtokomafont{publishers}{\sffamily}
|
||||
|
||||
% Use serif font for headings
|
||||
\addtokomafont{disposition}{\rmfamily}
|
||||
|
||||
% Let sections be formated as in: Aufgabe 1 -- Section title
|
||||
\renewcommand*{\sectionformat}{Aufgabe \thesection\autodot\enskip--\enskip}
|
||||
|
||||
% Let points of an exercise be printed as in: [__ / 2]
|
||||
\newkomafont{points}{\sffamily}
|
||||
\newcommand\points[2][1em]{\marginline{\framebox{{\usekomafont{points}\hspace{#1} \textbf{/} #2}}}}
|
||||
|
||||
\newcounter{task}
|
||||
\renewcommand{\thetask}{\@alph\c@task)}
|
||||
\newenvironment{tasks}
|
||||
{
|
||||
\begin{list}{\thetask}
|
||||
{
|
||||
\usecounter{task}
|
||||
\setlength{\leftmargin}{1.6em}
|
||||
}
|
||||
}{%
|
||||
\end{list}
|
||||
}
|
||||
|
||||
\DeclareNewTOC
|
||||
[
|
||||
type=algorithm,
|
||||
types=algorithms,
|
||||
float,
|
||||
floattype=4,
|
||||
name=Algorithmus,
|
||||
listname={Algorithmenverzeichnis}
|
||||
]
|
||||
{loa}
|
||||
159
übung_8/ngutils.sty
Normal file
159
übung_8/ngutils.sty
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
\NeedsTeXFormat{LaTeX2e}
|
||||
\ProvidesPackage{ngutils}[2026/06/05 Never's LaTeX utils]
|
||||
|
||||
\RequirePackage[ngerman]{babel}
|
||||
\RequirePackage{graphicx}
|
||||
\RequirePackage{tabularx}
|
||||
\RequirePackage{booktabs}
|
||||
\RequirePackage{listings}
|
||||
|
||||
\lstnewenvironment{pseudocode}[1][] %defines the algorithm listing environment
|
||||
{
|
||||
\renewcommand{\lstlistingname}{Algorithmus}
|
||||
\lstset{ %this is the stype
|
||||
mathescape=true,
|
||||
columns=fullflexible,
|
||||
basicstyle=\normalfont,
|
||||
identifierstyle=\scshape,
|
||||
keywordstyle=\bfseries,
|
||||
keywords={, and, or, not, new, if, then, else, while, for, in, to, up, down, foreach, do, return},
|
||||
commentstyle=\itshape,
|
||||
comment=[l]//,
|
||||
delim=[is][\normalfont]{|}{|},
|
||||
tabsize=3,
|
||||
frame=tb,
|
||||
framerule=1pt,
|
||||
#1 % this is to add specific settings to an usage of this environment (for instnce, the caption and referable label)
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
\newcommand{\seilpmi}{\Longleftarrow}
|
||||
|
||||
\newcommand{\NN}{\mathbb{N}}
|
||||
\newcommand{\ZZ}{\mathbb{Z}}
|
||||
\newcommand{\QQ}{\mathbb{Q}}
|
||||
\newcommand{\RR}{\mathbb{R}}
|
||||
\newcommand{\CC}{\mathbb{C}}
|
||||
\newcommand{\PP}{\mathbb{P}}
|
||||
|
||||
\newcommand{\Pe}{\mathrm{P}}
|
||||
\newcommand{\NPe}{\mathrm{NP}}
|
||||
|
||||
\newcommand{\Oh}{\mathcal{O}}
|
||||
\newcommand{\oh}{\scriptstyle{\mathcal{O}}}
|
||||
|
||||
\newcommand{\indeg}{\mathrm{indeg}}
|
||||
\newcommand{\outdeg}{\mathrm{outdeg}}
|
||||
\newcommand{\Eh}{\mathrm{E}}
|
||||
\newcommand{\Var}{\mathrm{Var}}
|
||||
\newcommand{\pot}{\mathcal{P}}
|
||||
\newcommand{\argmax}{\mathop{\mathrm{arg\,max}}}
|
||||
\newcommand{\argmin}{\mathop{\mathrm{arg\,min}}}
|
||||
|
||||
\newcommand{\parens}[1]{\left(#1\right)}
|
||||
\newcommand{\brackets}[1]{\left[#1\right]}
|
||||
\newcommand{\braces}[1]{\left\{#1\right\}}
|
||||
\newcommand{\angled}[1]{\left\langle#1\right\rangle}
|
||||
|
||||
\newcommand{\suchthat}{\;\middle\vert\;}
|
||||
|
||||
\newcommand{\tup}[1]{\parens{#1}}
|
||||
\newcommand{\interval}[2][b]{
|
||||
\if\detokenize{a}\detokenize{#1}%
|
||||
\left[#2\right[
|
||||
\fi
|
||||
\if\detokenize{b}\detokenize{#1}%
|
||||
\left[#2\right]
|
||||
\fi
|
||||
\if\detokenize{c}\detokenize{#1}%
|
||||
\left]#2\right[
|
||||
\fi
|
||||
\if\detokenize{d}\detokenize{#1}%
|
||||
\left]#2\right]
|
||||
\fi
|
||||
}
|
||||
\newcommand{\set}[2][]{
|
||||
\ifx&
|
||||
\braces{#2}
|
||||
\else
|
||||
\braces{#1 \suchthat #2}
|
||||
\fi
|
||||
}
|
||||
\newcommand{\arr}[1]{\angled{#1}}
|
||||
\newcommand{\abs}[1]{\left\vert#1\right\vert}
|
||||
\newcommand{\norm}[1]{\left\Vert#1\right\Vert}
|
||||
\newcommand{\ceil}[1]{\left\lceil#1\right\rceil}
|
||||
\newcommand{\floor}[1]{\left\lfloor#1\right\rfloor}
|
||||
|
||||
% \newcommand{\alg}[2]{{\normalfont\scshape#1}{\normalfont(#2)}}
|
||||
\newcommand{\algt}[1]{{\normalfont\scshape#1}}
|
||||
|
||||
\makeatletter
|
||||
\newcommand*{\alg@unstarred}[2]{{\normalfont\scshape#1}{\normalfont(#2)}}
|
||||
\newcommand*{\alg@starred}[1]{{\normalfont\scshape#1}}
|
||||
\newcommand*{\alg}{\@ifstar{\alg@starred}{\alg@unstarred}}
|
||||
\makeatother
|
||||
|
||||
\newcommand{\com}[1]{{\normalfont\itshape/\!\!/ #1}}
|
||||
|
||||
\newenvironment{algorithmic}[1][1em]{
|
||||
\begin{minipage}[t]{\dimexpr\linewidth}
|
||||
\bfseries
|
||||
\begin{tabbing}
|
||||
\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\kill
|
||||
}{%
|
||||
\end{tabbing}
|
||||
\end{minipage}
|
||||
}
|
||||
|
||||
% \newlength{\theoremskip}
|
||||
% \setlength{\theoremskip}{6em}
|
||||
%
|
||||
% \newcommand{\theoremfont}{\normalfont\bfseries}
|
||||
% \newcommand{\definitionfont}{\normalfont\bfseries}
|
||||
%
|
||||
% \newenvironment{theoremic}[3][]{
|
||||
% {#3 #2 #1}
|
||||
% \hfill
|
||||
% \begin{minipage}[t]{\the\dimexpr\linewidth-\theoremskip\relax}
|
||||
% }{
|
||||
% \end{minipage}
|
||||
% }
|
||||
%
|
||||
% \newenvironment{theorem}[1][]{
|
||||
% \begin{theoremic}[#1]{Satz}{\theoremfont}
|
||||
% }{
|
||||
% \end{theoremic}
|
||||
% }
|
||||
%
|
||||
% \newenvironment{lemma}[1][]{
|
||||
% \begin{theoremic}[#1]{Lemma}{\theoremfont}
|
||||
% }{
|
||||
% \end{theoremic}
|
||||
% }
|
||||
%
|
||||
% \newenvironment{corrolary}[1][]{
|
||||
% \begin{theoremic}[#1]{Korall}{\theoremfont}
|
||||
% }{
|
||||
% \end{theoremic}
|
||||
% }
|
||||
%
|
||||
% \newenvironment{proof}[1][]{
|
||||
% \begin{theoremic}[#1]{Beweis}{\theoremfont}
|
||||
% }{
|
||||
% \end{theoremic}
|
||||
% }
|
||||
%
|
||||
% \newenvironment{definition}[1][]{
|
||||
% \begin{theoremic}[#1]{Definition}{\theoremfont}
|
||||
% }{
|
||||
% \end{theoremic}
|
||||
% }
|
||||
%
|
||||
% \newenvironment{example}[1][]{
|
||||
% \begin{theoremic}[#1]{Beispiel}{\theoremfont}
|
||||
% }{
|
||||
% \end{theoremic}
|
||||
% }
|
||||
%
|
||||
BIN
übung_8/vw.jpg
Normal file
BIN
übung_8/vw.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 79 KiB |
Loading…
Add table
Add a link
Reference in a new issue