Anki Deck Changes

Commit: 634d3ed6 - update prim's dijkstra comparison

Author: obrhubr <obrhubr@gmail.com>

Date: 2025-12-26T15:14:55+01:00

Changes: 1 note(s) changed (0 added, 1 modified, 0 deleted)

Note 1: ETH::A&D

Deck: ETH::A&D
Note Type: Horvath Cloze
GUID: wD<:EQZU&2
modified

Before

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
Prim's Algorithm is similar to Dijkstra's with the difference that  \(d[v]\) is the minimum between current value and \(w(v*, v)\) instead of \(d[v^*] + w(v^*, v)\) .

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
Prim's Algorithm is similar to Dijkstra's with the difference that  \(d[v]\) is the minimum between current value and \(w(v*, v)\) instead of \(d[v^*] + w(v^*, v)\) .

Dijkstra's find the shortest distance to each vertex, thus it tracks the total.

Prim's needs to build the MST, thus it only cares about which vertex to choose next to find a (cheapest) safe-edge.

After

Front

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
Prim's Algorithm is similar to Dijkstra's with the difference that {{c1:: \(d[v] = \min \{d[v], w(v*, v)\}\) instead of \(d[v^*] + w(v^*, v)\) }}.

Back

ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
Prim's Algorithm is similar to Dijkstra's with the difference that {{c1:: \(d[v] = \min \{d[v], w(v*, v)\}\) instead of \(d[v^*] + w(v^*, v)\) }}.

Dijkstra's find the shortest distance to each vertex, thus it tracks the total. distance

Prim's needs to build the MST. As in the loop we add vertex \(v\) to the MST, we now want to know the new least distance to the MST for each node.
Field-by-field Comparison
Field Before After
Text <b>Prim's Algorithm</b>&nbsp;is similar to {{c1:: Dijkstra's}} with the difference that {{c1::&nbsp;\(d[v]\)&nbsp;is the minimum between current value and&nbsp;\(w(v*, v)\)&nbsp;instead of&nbsp;\(d[v^*] + w(v^*, v)\)&nbsp;}}. <b>Prim's Algorithm</b>&nbsp;is similar to {{c1:: Dijkstra's}} with the difference that {{c1::&nbsp;\(d[v] = \min \{d[v], w(v*, v)\}\)&nbsp;instead of&nbsp;\(d[v^*] + w(v^*, v)\)&nbsp;}}.
Extra Dijkstra's find the shortest distance to each vertex, thus it tracks the total.<br><br>Prim's needs to build the MST, thus it only cares about which vertex to choose next to find a (cheapest) safe-edge. Dijkstra's find the shortest distance to each vertex, thus it tracks the total. distance<br><br>Prim's needs to build the MST. As in the loop we add vertex&nbsp;\(v\)&nbsp;to the MST, we now want to know the new least distance to the MST for each node.
Tags: ETH::1._Semester::A&D::11._Minimum_Spanning_Trees::2._Prim's_Algorithm
↑ Top