11-30 Notes - Notes • Spanning Tree o Forms a tree(no...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 11-30-11 Notes • Spanning Tree o Forms a tree (no cycle) o Touches every vertex • Minimum spanning tree (MST) • How to find an MST o Prim’s Algorithm o Greedy Algorithm • Steps o Start from any vertex o Add t oT the lowest-weight edge in G that does not create a cycle o Stop when all V touched • Correctness of Prim’s algorithm o Prove by induction on verticies o Base case: 1 vertex o Suppose T is contained in a MST To we choose uv, u€T, v € T o Show that T U (u,v) T’ o By removing (x,y) adding (u,v) we get an MST To’ => w(To’) <= w(To) (w = weight) w(To’) = w(To) - w(x,y) + w(u,v) so, w (u,v) <= w(x,y) so, <=w(To) o To is an MST, To’ is also an MST • Heap o T = {E} A = INF B=3 C=9 D=8 o Add B, T={(B,E)} A=1 C=1 D=6 o Add A,B, T={(B,E),(A,B)} o Add B,C, T = {(B,E),(A,B),(B,C)} o Add C,D, T = {(B,E),(A,B),(B,C),(C,D)} • Prim: o Psudocode – same as code from last class • Takes nlogn+cm ...
View Full Document

This note was uploaded on 12/05/2011 for the course ENGINEERIN 131 taught by Professor Cytron during the Spring '11 term at Washington University in St. Louis.

Ask a homework question - tutors are online