diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..be1185b Binary files /dev/null and b/.DS_Store differ diff --git a/GA4/ga4.pdf b/GA4/ga4.pdf index a3e33e6..f9b70c0 100644 Binary files a/GA4/ga4.pdf and b/GA4/ga4.pdf differ diff --git a/GA4/ga4.tex b/GA4/ga4.tex index dc65579..5a043b5 100644 --- a/GA4/ga4.tex +++ b/GA4/ga4.tex @@ -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 (s, P[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} \ No newline at end of file