Corrections to GA4
This commit is contained in:
parent
e1cb103be5
commit
c393a6d332
3 changed files with 20 additions and 4 deletions
BIN
.DS_Store
vendored
Normal file
BIN
.DS_Store
vendored
Normal file
Binary file not shown.
BIN
GA4/ga4.pdf
BIN
GA4/ga4.pdf
Binary file not shown.
24
GA4/ga4.tex
24
GA4/ga4.tex
|
@ -35,6 +35,7 @@
|
||||||
\maketitle
|
\maketitle
|
||||||
\tableofcontents
|
\tableofcontents
|
||||||
\lstlistoflistings
|
\lstlistoflistings
|
||||||
|
{\color{white}{Will these be the right solutions? I have the answer: \url{https://imgur.com/a/yk9RPFs}}}
|
||||||
\newpage
|
\newpage
|
||||||
|
|
||||||
\section{Exercise 1}
|
\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}]
|
\begin{lstlisting}[caption=Solution for exercise 4 point 2, label={lst:ex4p1}]
|
||||||
FUNCTION MAKE-MST-MINIMAL(T=(V,E), weight, v, w, c):
|
FUNCTION MAKE-MST-MINIMAL(T=(V,E), weight, v, w, c):
|
||||||
if not IS-MST-MINIMAL(T, weight, v, w, c):
|
P[w] = NIL
|
||||||
$\textit{delete edge where IS-MST-MINIMAL stopped from T}$
|
DEFINE-PARENT(T, P, Adj[w], w)
|
||||||
$\textit{add (v, w) to T}$
|
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 (s, P[s]) from T}$ // O(|V|) cost operation
|
||||||
|
$\textit{add (v, w) to T}$ // constant cost
|
||||||
\end{lstlisting}
|
\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}
|
\end{document}
|
Reference in a new issue