{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture20-mst-prims

Lecture20-mst-prims - This work is licensed under a...

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

View Full Document Right Arrow Icon
CS 312: Algorithm Analysis Lecture #20: Minimal Spanning Trees; Prim’s Algorithm This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. Slides by: Eric Ringger, with figures from Dasgupta et al.
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
Announcements § Homework #13 due now § Project #4 - “Intelligent scissors” § Early: Monday § Due: Wednesday § Start early, finish early! § Clarification on SimpleScissors: When two or more directions have equal weight, ties should be broken as follows: Prefer pixels in clockwise order, starting with the pixel to the north (upwards in the image; lower y-coordinate).
Background image of page 2
Objectives § More Greedy Algorithms § Analysis of Kruskal’s Algorithm § Requires Implementation of Disjoint Sets § Prim’s Algorithm for MST § Head-to-head analysis of Prim’s and Kruskal’s
Background image of page 3

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

View Full Document Right Arrow Icon
Greedy Algorithms § Which greedy algorithms have you seen so far? § Distinguish between “thoughtful” and “not- so-thoughtful” greedy algorithms § E.g., Intelligent scissors vs. Simple scissors
Background image of page 4
Kruskal’s Algorithm Objective: Identify: - Important operations - Elements of a Greedy algorithm break if size(X) == |V|-1
Background image of page 5

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

View Full Document Right Arrow Icon
Data Structure For Disjoint Sets § makeset(x): create a singleton set containing just x § find(x): find the set to which x belongs § union(x, y): merge the sets containing x and y How would you implement a data structure providing these methods?
Background image of page 6
Disjoint Sets as Shallow, Directed Trees {A,C,D,F,G,H} {B,E}
Background image of page 7

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

View Full Document Right Arrow Icon
Disjoint Set Operations
Background image of page 8
Disjoint Set Operations
Background image of page 9

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

View Full Document Right Arrow Icon
Disjoint Set Operations Let’s try an example …
Background image of page 10
Example Disjoint Set Ops
Background image of page 11

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

View Full Document Right Arrow Icon
Example (cont.)
Background image of page 12
Example (cont.)
Background image of page 13

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

View Full Document Right Arrow Icon
Claim § For a given set S, no tree representing disjoint sets in this manner is every deeper than log |S| § If you have a counter-example, I want to see it!
Background image of page 14
Analyze: Disjoint Set Operations
Background image of page 15

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

View Full Document Right Arrow Icon
Background image of page 16
Lemma Lemma : O(log|V|)=O(log|E|)
Background image of page 17

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

View Full Document Right Arrow Icon
Kruskal’s Algorithm break if size(X) == |V|-1
Background image of page 18
Image of page 19
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}