# lec7 - CS 323/700 Lecture 7 Design and Analysis of...

This preview shows pages 1–5. Sign up to view the full content.

n CS 323/700 ± ± Lecture 7 o Design and Analysis of Algorithms Hoeteck Wee · [email protected] http://algorithms.qwriting.org/

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

View Full Document
Spanning trees DEFINITION. spanning tree I input: weighted, undirected, connected graph I spanning tree: subset of edges that forms a tree and every pair of vertices is connected I cost(spanning tree) = sum of edge weights a b c d e f g 7 8 5 9 7 5 15 6 8 9 11 PROBLEM. minimum spanning tree (MST) problem I ﬁnd a spanning tree of the smallest cost I non-trivial: complete graph Kn has ( n - 1 )! = n Ω( n ) spanning trees. I see two greedy algorithms for MST Hoeteck Wee CS 323/700 Feb 24, 2010 2 / 12
Minimum spanning tree APPLICATION. I input: a set of locations V = { v 1 , . . . , vn } , with costs for building a (undirected) link between some pairs of locations I goal: build the cheapest communication network s.t. every pair of locations is connected (cost of a network = sum of link costs) a b c d e f g 7 8 5 9 7 5 15 6 8 9 11 FACTS. I cheapest communication network must be a spanning tree (removing any edge from a cycle in a connected graph leaves the graph connected) I every n -node tree has exactly n - 1 edges Hoeteck Wee CS 323/700 Feb 24, 2010 3 / 12

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

View Full Document
Kruskal’s MST algorithm ALGORITHM. incrementally add least cost edges that do not make a cycle sort edges by cost, T = [] for e in edges: if adding e to T does not create a cycle: T.append(e) return
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 12

lec7 - CS 323/700 Lecture 7 Design and Analysis of...

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

View Full Document
Ask a homework question - tutors are online