Anki Deck Changes

Commit: be8822ff - mst cards

Author: obrhubr <obrhubr@gmail.com>

Date: 2025-12-24T11:18:34+01:00

Changes: 19 note(s) changed (11 added, 8 modified, 0 deleted)

ℹ️ Cosmetic Changes Hidden: 5 note(s) had formatting-only changes and are not shown below

Note 1: ETH::A&D

Deck: ETH::A&D
Note Type: Algorithms
GUID: cKo%p6:M08
modified

Before

Front

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
Runtime of
Prim

Runtime: {{c1::\( \mathcal{O}((|E| + |V|) \cdot \log|V|)\)}}

Approach:

Uses:
?


After

Front

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm PlsFix::DUPLICATE
Runtime of
Prim

Runtime: {{c1::\( \mathcal{O}((|E| + |V|) \cdot \log|V|)\)}}

Approach:

Uses: Runtime: {{c1::
\( \mathcal{O}((|E| + |V|) \cdot \log|V|)\)}}

Approach:

Uses:
?


Field-by-field Comparison
Field Before After
Name <div style="text-align: center;"><b>Prim</b></div><div><br></div><div><b>Runtime</b>: {{c1::\( \mathcal{O}((|E| + |V|) \cdot \log|V|)\)}}</div><div><br></div><div><b>Approach</b>: {{c2::We start at a given vertex. To this subtree we add one-by-one the cheapest edge connecting the subtree to another component until all vertices are connected. The implementation is very similar to Dijkstra.}}</div><div><br></div><div><b>Uses</b>: {{c3::Find MST in weighted, undirected graph}}</div> <div style="text-align: center;"><b>Prim</b></div><div><br></div><div><b>Runtime</b>: {{c1::\( \mathcal{O}((|E| + |V|) \cdot \log|V|)\)}}</div><div><br></div><div><b>Approach</b>: {{c2::We start at a given vertex. To this subtree we add one-by-one the cheapest edge connecting the subtree to another component until all vertices are connected. The implementation is very similar to Dijkstra.}}</div><div><br></div><div><b>Uses</b>: {{c3::Find MST in weighted, undirected graph}}<b>Runtime</b>: {{c1::</div><div>\( \mathcal{O}((|E| + |V|) \cdot \log|V|)\)}}</div><div><br></div><div><b>Approach</b>: {{c2::We start at a given vertex. To this subtree we add one-by-one the cheapest edge connecting the subtree to another component until all vertices are connected. The implementation is very similar to Dijkstra.}}</div><div><br></div><div><b>Uses</b>: {{c3::Find MST in weighted, undirected graph}}</div>
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm PlsFix::DUPLICATE

Note 2: ETH::A&D

Deck: ETH::A&D
Note Type: Algorithms
GUID: kn@H8`z>0t
modified

Before

Front

ETH::1._Semester::A&D::09._Graph_Search::1._Depth_First_Search
Runtime of DFS (Depth First Search)?

Back

ETH::1._Semester::A&D::09._Graph_Search::1._Depth_First_Search
Runtime of DFS (Depth First Search)?

\( \mathcal{O}(|E| + |V|) \) (using Adjacency List)
Can be efficiently implemented using a stack.

After

Front

ETH::1._Semester::A&D::09._Graph_Search::1._Depth_First_Search
Runtime of DFS (Depth First Search)?

Back

ETH::1._Semester::A&D::09._Graph_Search::1._Depth_First_Search
Runtime of DFS (Depth First Search)?

\( \mathcal{O}(|E| + |V|) \) (using Adjacency List)
Can be efficiently implemented using a stack.
Field-by-field Comparison
Field Before After
Use Case Find Connected Components, Toposort
Tags: ETH::1._Semester::A&D::09._Graph_Search::1._Depth_First_Search

Note 3: ETH::A&D

Deck: ETH::A&D
Note Type: Algorithms
GUID: y@l`JCIJ<4
modified

Before

Front

ETH::1._Semester::A&D::09._Graph_Search::2._Breadth_First_Search
Runtime of BFS (Breadth First Search)?

Back

ETH::1._Semester::A&D::09._Graph_Search::2._Breadth_First_Search
Runtime of BFS (Breadth First Search)?

\(O(|V|+|E|)\) (Adjacency List)
The runtime of BFS:
  1. each loop we take \(O(1 + \deg(u))\) time (go through the vertex \(u\)'s edges
  2. We loop a total of \(|V|\) times (we visit each edge max. 1 time)

After

Front

ETH::1._Semester::A&D::09._Graph_Search::2._Breadth_First_Search
Runtime of BFS (Breadth First Search)?

Back

ETH::1._Semester::A&D::09._Graph_Search::2._Breadth_First_Search
Runtime of BFS (Breadth First Search)?

\(O(|V|+|E|)\) (Adjacency List)
The runtime of BFS:
  1. each loop we take \(O(1 + \deg(u))\) time (go through the vertex \(u\)'s edges
  2. We loop a total of \(|V|\) times (we visit each edge max. 1 time)
Field-by-field Comparison
Field Before After
Use Case Shortest Path in a directed graph Shortest Path in a directed graph, Bipartite Test
Tags: ETH::1._Semester::A&D::09._Graph_Search::2._Breadth_First_Search

Note 4: ETH::A&D

Deck: ETH::A&D
Note Type: Horvath Classic
GUID: H>#zg]RQy9
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees
Do we need positive edges for an MST?

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees
Do we need positive edges for an MST?

No, the algorithms can handle negative edges as there are no distances to compute.
Field-by-field Comparison
Field Before After
Front Do we need positive edges for an MST?
Back No, the algorithms can handle negative edges as there are no distances to compute.
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees

Note 5: ETH::A&D

Deck: ETH::A&D
Note Type: Algorithms
GUID: dl`?#
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::1._Boruvka's_Algorithm
Runtime of Boruvka's Algorithm?

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::1._Boruvka's_Algorithm
Runtime of Boruvka's Algorithm?

\(O((|V| + |E|) \cdot \log |V|)\)

During each iteration, we examine all edges to find the cheapest one: \(O(|V| + |E|)\):
  1. Run DFS to find the connected components: \(O(|V| + |E|)\)
  2. Find the cheapest one \(O(|E|)\)
We iterate a total of \(\log_2 |V|\) times as each iteration halves the number of connected components.
Field-by-field Comparison
Field Before After
Name Boruvka's Algorithm
Runtime \(O((|V| + |E|) \cdot \log |V|)\)<br><br>During each iteration, we examine all edges to find the cheapest one:&nbsp;\(O(|V| + |E|)\):<br><ol><li>Run DFS to find the connected components:&nbsp;\(O(|V| + |E|)\)</li><li>Find the cheapest one&nbsp;\(O(|E|)\)</li></ol>We iterate a total of&nbsp;\(\log_2 |V|\)&nbsp;times as each iteration halves the number of connected components.
Requirements undirected, connected, weighted Graph.
Approach <ol><li>For Boruvka, we start with the set of edges&nbsp;\(F = \emptyset\). We treat each of the&nbsp;<em>isolated vertices</em>&nbsp;of the graph as it’s&nbsp;<em>own connected component</em>.</li><li>Each vertex marks it’s cheapest outgoing edge as a&nbsp;<em>safe edge</em>&nbsp;(making use of the cut property). We add these to&nbsp;\(F\).</li></ol><ul><li>Note that some of the edges might be chosen by both adjacent vertices, we still only add them once.<br><img src="paste-053ccf0acc6d560628bd8518b928a0d6c2687cb1.jpg"></li></ul><ol><li>Now, repeat by finding the cheapest outgoing edge for each component. Do this until all are connected.</li><li>\(F\)&nbsp;constitutes the edges of the MST.</li></ol>
Pseudocode <img src="paste-7f2fe108c849a581658c052b210a79e0897f8fe0.jpg">
Use Case Find an MST
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::1._Boruvka's_Algorithm

Note 6: ETH::A&D

Deck: ETH::A&D
Note Type: Algorithms
GUID: m`oj
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
Runtime of Prim's Algorithm?

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
Runtime of Prim's Algorithm?

\(O((|V| + |E|) \log |V|)\) (Adjacency List, otherwise \(\Theta(|V|^2)\) like Dijkstra's)
Field-by-field Comparison
Field Before After
Name Prim's Algorithm
Runtime \(O((|V| + |E|) \log |V|)\)&nbsp;(Adjacency List, otherwise&nbsp;\(\Theta(|V|^2)\)&nbsp;like Dijkstra's)
Requirements undirected, connected, weighted Graph
Approach <div>Prim’s algorithm starts with a single vertex and grows the MST outwards from that seed.</div> <ol> <li><strong>Initialisation:</strong><ul> <li>Select and arbitrary starting vertex&nbsp;\(s\)&nbsp;and empty set&nbsp;\(F\)</li> <li>Set&nbsp;\(S = {s}\)&nbsp;tracks the vertices in the MST</li> <li>Each vertex gets a <code>key[v] =</code> representing the cheapest known connection cost to&nbsp;\(v\):<ul> <li>\(\infty\)&nbsp;if no edge connects&nbsp;\(s\)&nbsp;to&nbsp;\(v\)</li> <li>\(w(s, v)\)&nbsp;if edge&nbsp;\((s, v)\)&nbsp;exists</li> </ul> </li> <li>Use a priority queue&nbsp;\(Q\)&nbsp;(<em>Min-Heap</em>) to store the vertices, in order of lowest <code>key</code> cost</li> </ul> </li> <li><strong>Iteration:</strong><ul> <li><em>Select and add</em> Extract the vertex&nbsp;\(u\)&nbsp;with the minimum <code>key</code> from&nbsp;\(Q\). This is the cheapest to connected to the current MST. Add&nbsp;\(u\)&nbsp;to&nbsp;\(S\).</li> <li><em>Update Neighbours</em> For each neighbour&nbsp;<b>\(v\)&nbsp;</b>of&nbsp;\(u\)&nbsp;<em>not</em> in&nbsp;\(S\):<ul> <li>If&nbsp;\(w(u, v) &lt; \text{key}[v]\)&nbsp;update <code>key[v] = w(u, v)</code> and update the priority in&nbsp;\(Q\).<ul> <li>This discovers potentially cheaper connections to vertices outside the current MST. If a <em>cheaper edge</em> to&nbsp;\(v\)&nbsp;is found, the current value in <code>key[v]</code> cannot be part of the MST</li> </ul> </li> </ul> </li> </ul> </li> <li><strong>Termination:</strong> When&nbsp;\(Q\)&nbsp;is empty, all vertices are in&nbsp;\(S\)&nbsp;and connected, and the edges chosen are in the MST (tracked in the set&nbsp;\(F\)&nbsp;through updates).</li></ol>
Pseudocode <img src="paste-7d28e852262c66f4efd97974921c1a6120b2c2a1.jpg">
Use Case Find MST
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm

Note 7: ETH::A&D

Deck: ETH::A&D
Note Type: Horvath Cloze
GUID: x@F_EbzW}O
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
Prim's Algorithm Invariants: 
The priority queue \(H = V \setminus S\) (\(V\) set of all vertices, \(S\) vertices currently in the MST) never contains a vertex already in the MST.

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
Prim's Algorithm Invariants: 
The priority queue \(H = V \setminus S\) (\(V\) set of all vertices, \(S\) vertices currently in the MST) never contains a vertex already in the MST.
Field-by-field Comparison
Field Before After
Text Prim's Algorithm Invariants:&nbsp;<br>The priority queue \(H = V \setminus S\)&nbsp;(\(V\)&nbsp;set of all vertices,&nbsp;\(S\)&nbsp;vertices currently in the MST) {{c1::never contains a vertex already in the MST}}.
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm

Note 8: ETH::A&D

Deck: ETH::A&D
Note Type: Horvath Cloze
GUID: v|.y5zi[:;
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
Prim's Algorithm Invariants:

The distances "d[.] = " in the distance array are the values of the vertices in the priority queue (see line decrease_key(H, v, d[v])).

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
Prim's Algorithm Invariants:

The distances "d[.] = " in the distance array are the values of the vertices in the priority queue (see line decrease_key(H, v, d[v])).

Field-by-field Comparison
Field Before After
Text Prim's Algorithm Invariants:<br><br><div>The distances "d[.] = " in the distance array are {{c1::the values of the vertices in the priority queue (see line decrease_key(H, v, d[v]))}}.</div>
Extra <img src="paste-c6f5e360bdfa85548214127036942fc80a2cde0e.jpg">
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm

Note 9: ETH::A&D

Deck: ETH::A&D
Note Type: Horvath Cloze
GUID: IV81kgA3~6
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
 Prim's Algorithm Invariants:
\(\forall v \not \in S, v \neq s\), \(d[v] = \) {{c1:: \(\min \{ w(u, v) \ | \ (u, v) \in E, u \in S \}\)(\(\infty\) if no such edge exists)}}.

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
 Prim's Algorithm Invariants:
\(\forall v \not \in S, v \neq s\), \(d[v] = \) {{c1:: \(\min \{ w(u, v) \ | \ (u, v) \in E, u \in S \}\)(\(\infty\) if no such edge exists)}}.

The 3rd invariant \[d[v] = \begin{cases} 0, & \text{if } v = s \text{ (the starting vertex)} \\ \min_{(u,v) \in E : u \in S} {w(u,v)}, & \text{if } v \in V \setminus S \text{ and } \exists (u,v) \in E \text{ with } u \in S \\ \infty, & \text{if } v \in V \setminus S \text{ and } \nexists (u,v) \in E \text{ with } u \in S \end{cases}\]ensures that d[v] always reflects the minimum cost to reach vertex v from the current MST.

We always want to add the vertex with the cheapest edge connecting it to the MST, thus this invariant has to hold in order for the algorithm to be correct.
Field-by-field Comparison
Field Before After
Text &nbsp;Prim's Algorithm Invariants:<br>\(\forall v \not \in S, v \neq s\),&nbsp;\(d[v] = \)&nbsp;{{c1::&nbsp;\(\min \{ w(u, v) \ | \ (u, v) \in E, u \in S \}\)(\(\infty\)&nbsp;if no such edge exists)}}.
Extra <div>The 3rd invariant&nbsp;\[d[v] = \begin{cases} 0, &amp; \text{if } v = s \text{ (the starting vertex)} \\ \min_{(u,v) \in E : u \in S} {w(u,v)}, &amp; \text{if } v \in V \setminus S \text{ and } \exists (u,v) \in E \text{ with } u \in S \\ \infty, &amp; \text{if } v \in V \setminus S \text{ and } \nexists (u,v) \in E \text{ with } u \in S \end{cases}\]ensures that d[v] always reflects the minimum cost to reach vertex v from the current MST.</div><div><br></div> <div>We always want to add the vertex with the cheapest edge connecting it to the MST, thus this invariant has to hold in order for the algorithm to be correct.</div>
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm

Note 10: ETH::A&D

Deck: ETH::A&D
Note Type: Algorithms
GUID: T?I`@dy&K
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm
Runtime of Kruskal's Algorithm?

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm
Runtime of Kruskal's Algorithm?

\(O(|E| \log |E| + |V| \log |V|)\)

Outer loop: Iterate \(|E|\) times at most:
Inner loop: find and union take \(O(\log |V|)\) per call amortised, thus \(O(|V| \log |V|)\) total.
This requires the Union Find Datastructure
Field-by-field Comparison
Field Before After
Name Kruskal's Algorithm
Runtime \(O(|E| \log |E| + |V| \log |V|)\)<br><br><b>Outer loop:&nbsp;</b>Iterate&nbsp;\(|E|\)&nbsp;times at most:<br><b>Inner loop:&nbsp;</b>find and union take&nbsp;\(O(\log |V|)\)&nbsp;per call <b>amortised</b>, thus&nbsp;\(O(|V| \log |V|)\)&nbsp;total.
Requirements Undirected, weighted, connected graph
Approach <ol><li><b>Initialisation</b>: Start with an empty set \(F = \emptyset\)&nbsp;to represent the MST edges. Initially each vertex is it’s own seperate ZHK.&nbsp;</li><li><b>Iteration</b>: Sort all edges in the graphs by weight in increasing order. For each edge \((u, v)\)&nbsp;in sorted order: <br>If adding&nbsp;\((u, v)\)&nbsp;does not create a cycle (i.e.&nbsp;\(u\)&nbsp;and&nbsp;\(v\)&nbsp;in different ZHKs) <br>Add&nbsp;\((u, v)\)&nbsp;to&nbsp;\(F\). Merge the ZHKs of&nbsp;\(u\)&nbsp;and&nbsp;\(v\)</li><li>Stop: once we have&nbsp;\(n-1\)&nbsp;edges</li></ol><div>The operation of checking if there is no cycle can be done efficiently using the check of&nbsp;\(u\)&nbsp;and&nbsp;\(v\)&nbsp;being in different ZHKs.&nbsp;</div><div>This can be done efficiently using the <b>Union-Find datastructure</b>.</div>
Pseudocode <img src="paste-4f95b1dbfefb25bbfd8327342ed84d0141d63587.jpg">
Use Case Find MST
Extra Info This requires the Union Find Datastructure
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm

Note 11: ETH::A&D

Deck: ETH::A&D
Note Type: Horvath Cloze
GUID: ea8^2Vp8-y
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find
Union-Find datastructure methods:
  • make(u, v) creates the DS for \(F = \emptyset\)
  • same(u,v) test  if \(u, v\) in the same component
  • union(u,v) merge ZHKs of \(u, v\)

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find
Union-Find datastructure methods:
  • make(u, v) creates the DS for \(F = \emptyset\)
  • same(u,v) test  if \(u, v\) in the same component
  • union(u,v) merge ZHKs of \(u, v\)
Field-by-field Comparison
Field Before After
Text <b>Union-Find</b>&nbsp;datastructure methods:<br><ul><li>{{c1::<b>make(u, v)</b>&nbsp;creates the DS for&nbsp;\(F = \emptyset\)}}<br></li><li>{{c2::<b>same(u,v)&nbsp;</b>test&nbsp; if \(u, v\)&nbsp;in the same component}}</li><li>{{c3::<b>union(u,v)</b>&nbsp;merge ZHKs of&nbsp;\(u, v\)}}<br></li></ul>
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find

Note 12: ETH::A&D

Deck: ETH::A&D
Note Type: Horvath Cloze
GUID: oWyDyQ_9bL
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find
After adding \(x\) edges to the Union-Find DS, the repr array contains \(n-x\) components (different values).

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find
After adding \(x\) edges to the Union-Find DS, the repr array contains \(n-x\) components (different values).

Each added edge removes one unconnected component.
Field-by-field Comparison
Field Before After
Text After adding&nbsp;\(x\)&nbsp;edges to the Union-Find DS, the&nbsp;<b>repr</b>&nbsp;array contains {{c1::\(n-x\)&nbsp;components (different values)}}.
Extra Each added edge <i>removes one unconnected component</i>.
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find

Note 13: ETH::A&D

Deck: ETH::A&D
Note Type: Horvath Cloze
GUID: hv)-{h!@?x
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find
The amortised runtime of union in the Union-Find DS is  \(O(|V| \log |V|)\).

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find
The amortised runtime of union in the Union-Find DS is  \(O(|V| \log |V|)\).

union takes \(\Theta(\min \{ |ZHK(u)| , |ZHK(v)| \}\). In the worst case, the minimum is \(|V| / 2\) as both have the same size.

Therefore over all loops, this would take \(O(|V| \log |V|)\) time, as on average we only take \(O(\log |V|)\) time.
The graph stays worst case, this is the average of the calls in the worst case.
Field-by-field Comparison
Field Before After
Text The amortised runtime of&nbsp;<b>union</b>&nbsp;in the Union-Find DS is {{c1::&nbsp;\(O(|V| \log |V|)\)}}.
Extra union takes \(\Theta(\min \{ |ZHK(u)| , |ZHK(v)| \}\). In the worst case, the minimum is \(|V| / 2\)&nbsp;as both have the same size.<br><br>Therefore over all loops, this would take \(O(|V| \log |V|)\)&nbsp;time, as&nbsp;<i>on average</i>&nbsp;we only take&nbsp;\(O(\log |V|)\)&nbsp;time.<br><i>The graph stays worst case, this is the average of the calls in the worst case.</i>
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find

Note 14: ETH::A&D

Deck: ETH::A&D
Note Type: Horvath Classic
GUID: FS|421SN1o
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find
Explain how unions works in the optimised Union-Find:

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find
Explain how unions works in the optimised Union-Find:

Arrays:
  • rep, where rep[v] gives the representative of \(v\).
  • members, where members[rep[v]] which contains all members of the ZHK of \(v\)
  • rank, where rank[rep[v]] contains the size of the ZHK of \(v\).
We always merge the smaller ZHK into the bigger to minimise updates.

We update the reps, then the membership lists and finally the size
Field-by-field Comparison
Field Before After
Front Explain how unions works in the optimised&nbsp;<b>Union-Find:</b>
Back Arrays:<br><ul><li><b>rep</b>, where&nbsp;<b>rep[v]</b>&nbsp;gives the representative of \(v\).</li><li><b>members</b>, where&nbsp;<b>members[rep[v]]&nbsp;</b>which contains all members of the ZHK of&nbsp;\(v\)<br></li><li><b>rank</b>, where&nbsp;<b>rank[rep[v]]</b>&nbsp;contains the size of the ZHK of \(v\).</li></ul><div>We always merge the smaller ZHK into the bigger to minimise updates.</div><img src="paste-5129796b3ae6c46edebbaae726a47f0c892c2435.jpg"><br>We update the reps, then the membership lists and finally the size
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::3._Kruskal's_Algorithm::1._Union_Find
↑ Top