Lecture14

Lecture14 - Lecture 14 More about implementation Only V-1...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 170 More about implementation Only V-1 edges were used, the rest - wasted. Idea: » keep nodes in the heap, instead of edges. » Key: distance of node from A over a single edge. » Initially: key(v) = infinity , for all v. key(root) = 0 . So why does this work ??? x root vvx E key v key v w vx xx A  Repeat: do: Pick smallest-key , add to . : () m in ( () , ( ) ) Lecture 14, Nov 11 2010 171 Alternative Implementations Total: O(E) decrease-key, O(V) extract-min. extract min decrease key Total array ( ) heap Fib. heap OV O O EV O O VV E ( ) (log ) (log ) ( log ) (log ) ( ) ( log ) 1 2 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 172 Kruskal’s Algorithm Main loop: » Scan edges in increasing order of weight » Add current edge to output if no loop created. Why does this result in MST ?? » Observation: min-weight edge is always in MST » Proof: Assume there exists a tree without this edge. Add this edge to the tree - this creates a cycle . Delete max-weight edge on this cycle, we get a lighter tree !
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 5

Lecture14 - Lecture 14 More about implementation Only V-1...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online