Lecture19-greedy-minspanningtree

Kruskals algorithm 1 2 3 1 2 4 5 6 3 8 7 4 6 4 5 6 7

This preview shows page 23 - 35 out of 35 pages.

Kruskal’s Algorithm 1 2 3 1 2 4 5 6 3 8 7 4 6 4 5 6 7 3 4 1: {1,2} 2: {2,3} 3: {4,5} 3: {6,7} 4: {1,4} 4: {2,5} 4: {4,7} 5: {3,5} {1,2}{3}{4}{5}{6}{7} Process each edge in order {1,2,3}{4}{5}{6}{7}
Image of page 23

Subscribe to view the full document.

Kruskal’s Algorithm 1 2 3 1 2 4 5 6 3 8 7 4 6 4 5 6 7 3 4 1: {1,2} 2: {2,3} 3: {4,5} 3: {6,7} 4: {1,4} 4: {2,5} 4: {4,7} 5: {3,5} {1,2}{3}{4}{5}{6}{7} {1,2,3}{4}{5}{6}{7} {1,2,3}{4,5}{6}{7}
Image of page 24
Kruskal’s Algorithm 1 2 3 1 2 4 5 6 3 8 7 4 6 4 5 6 7 3 4 1: {1,2} 2: {2,3} 3: {4,5} 3: {6,7} 4: {1,4} 4: {2,5} 4: {4,7} 5: {3,5} {1,2}{3}{4}{5}{6}{7} {1,2,3}{4}{5}{6}{7} {1,2,3}{4,5}{6}{7} {1,2,3}{4,5}{6,7}
Image of page 25

Subscribe to view the full document.

Kruskal’s Algorithm 1 2 3 1 2 4 5 6 3 8 7 4 6 4 5 6 7 3 4 1: {1,2} 2: {2,3} 3: {4,5} 3: {6,7} 4: {1,4} 4: {2,5} 4: {4,7} 5: {3,5} {1,2}{3}{4}{5}{6}{7} {1,2,3}{4}{5}{6}{7} {1,2,3}{4,5}{6}{7} {1,2,3}{4,5}{6,7} {1,2,3,4,5}{6,7}
Image of page 26
Kruskal’s Algorithm 1 2 3 1 2 4 5 6 3 8 7 4 6 4 5 6 7 3 4 1: {1,2} 2: {2,3} 3: {4,5} 3: {6,7} 4: {1,4} 4: {2,5} 4: {4,7} 5: {3,5} {1,2}{3}{4}{5}{6}{7} Must join separate components {1,2,3}{4}{5}{6}{7} {1,2,3}{4,5}{6}{7} {1,2,3}{4,5}{6,7} {1,2,3,4,5}{6,7} rejected
Image of page 27

Subscribe to view the full document.

Kruskal’s Algorithm 1 2 3 1 2 4 5 6 3 8 7 4 6 4 5 6 7 3 4 1: {1,2} 2: {2,3} 3: {4,5} 3: {6,7} 4: {1,4} 4: {2,5} 4: {4,7} 5: {3,5} {1,2}{3}{4}{5}{6}{7} Stop when all vertices connected {1,2,3}{4}{5}{6}{7} {1,2,3}{4,5}{6}{7} {1,2,3}{4,5}{6,7} {1,2,3,4,5}{6,7} rejected {1,2,3,4,5,6,7} done
Image of page 28
Kruskal’s Algorithm Objective: Identify: - Important operations - Elements of a Greedy algorithm break if size(X) == |V|-1
Image of page 29

Subscribe to view the full document.

Kruskal’s Algorithm Objective: Identify: - Important operations - Elements of a Greedy algorithm break if size(X) == |V|-1
Image of page 30
3 Questions § Is it correct? § Now § How long does it take? § Next time § Can we do better? § Next time
Image of page 31

Subscribe to view the full document.

Correctness § Depends on the idea of a “cut” § Cut Property (a Lemma) : Suppose edges X are part of a minimum spanning tree of G=(V,E). Pick any subset of nodes S for which X does not cross between S and V-S, and let e be the lightest edge across this partition. Then X U {e} is part of some MST
Image of page 32
Correctness: Kruskal’s Algorithm Theorem: Kruskal’s Algorithm finds a minimum spanning tree Basis : X =  and G is connected so a solution must exist
Image of page 33

Subscribe to view the full document.

Correctness: Kruskal’s Algorithm Theorem: Kruskal’s Algorithm finds a minimum spanning tree Induction Step : Assume X is part of an MST u 1 2 v 3 8 4 6 4 5 6 7 3 4 S X E S vs. V-S is a cut No edge in X leaves S e ={ u,v } is lightest edge that leaves X Cut Property holds X U {e} is part of an MST
Image of page 34
Assignment § HW #13 § Due Tuesday (virtual Monday)
Image of page 35
You've reached the end of this preview.
  • Spring '08
  • Jones,M
  • Greedy algorithm, Kruskal's algorithm

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern