Corrections to GA4

This commit is contained in:
Claudio Maggioni 2019-05-27 16:12:32 +02:00
parent e1cb103be5
commit 8ab9d5118b
3 changed files with 20 additions and 4 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

View file

@ -35,6 +35,7 @@
\maketitle
\tableofcontents
\lstlistoflistings
{\color{white}{Will these be the right solutions? I have the answer: \url{https://imgur.com/a/yk9RPFs}}}
\newpage
\section{Exercise 1}
@ -222,11 +223,26 @@ of vertices (i.e.: $|E_T| = |V| - 1$).
\begin{lstlisting}[caption=Solution for exercise 4 point 2, label={lst:ex4p1}]
FUNCTION MAKE-MST-MINIMAL(T=(V,E), weight, v, w, c):
if not IS-MST-MINIMAL(T, weight, v, w, c):
$\textit{delete edge where IS-MST-MINIMAL stopped from T}$
$\textit{add (v, w) to T}$
P[w] = NIL
DEFINE-PARENT(T, P, Adj[w], w)
s = P[s]
s_max = s
max = weight($\textit{edge}$ (s, P[s]))
while s $\neq$ w:
edge_w = weight($\textit{edge}$ (s, P[s]))
if edge_w > max:
max = edge_w
s_max = s
s = P[s]
if max < c:
return
else:
$\textit{remove edge (max\_s, P[max\_s]) from T}$ // O(|V|) cost operation
$\textit{add (v, w) to T}$ // constant cost
\end{lstlisting}
For what said before, this algorithm updates $T$ to a valid MST and runs in $O(|V_T|)$ which is always $< O(|E|)$.
For what said before, this algorithm updates $T$ to a valid MST and runs in $O(|V_T|)$ which is always $< O(|E|)$. In order to find
the new MST, we need to find remove the edge with highest weight in the path from $v$ to $w$ and add $(v, w)$ to the MST.
\end{document}