Chapter 3: Optimal Trees and Branchings - UKP
Chapter 3: Optimal Trees and Branchings - UKP
Chapter 3: Optimal Trees and Branchings - UKP
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Optimal</strong> <strong>Trees</strong> <strong>and</strong> <strong>Branchings</strong><br />
Complexity of Prim’s Algorithm<br />
lines (1)-(3): Initialization in O(n)<br />
lines (4) <strong>and</strong> (5) in O(1)<br />
lines (6) <strong>and</strong> (7): n insert-operations<br />
line (8): exactly n passes through the loop<br />
line (9): in total n find-min- und delete-min-operations<br />
lines (10) - (14): every edge is touched once, that is O(m) + m decrease-key-operations.<br />
line (11): the test if u ∈ Q can be done in O(1) with a boolean auxiliary array (must be<br />
updated upon insertion / deletion).<br />
If we implement the priority queue as a binary heap, the find-min-operations might be done<br />
in O(1), the insert-, delete-min- <strong>and</strong> decrease-key-operations in O(log n) each.<br />
In total, this amounts to a complexity of O(m log n) .<br />
Efficient Graph Algorithms | Wolfgang Stille | WS 2011/2012 | <strong>Chapter</strong> III - <strong>Optimal</strong> <strong>Trees</strong> <strong>and</strong> <strong>Branchings</strong> | 35