This preview shows page 1. Sign up to view the full content.
Unformatted text preview: he smallest weigh. (Namely, e1 is the first edge chosen by Kruskal's algorithm.) c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 14 / 49 Optimal Substructure Property for MST Example
Optimal Substructure Property for MST Let G = (V, E) be a connected graph with edge weight. Let e1 = (x, y) be the edge with the smallest weigh. (Namely, e1 is the first edge chosen by Kruskal's algorithm.) Let G = (V , E ) be the graph obtained from G by merging x and y: c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 14 / 49 Optimal Substructure Property for MST Example
Optimal Substructure Property for MST Let G = (V, E) be a connected graph with edge weight. Let e1 = (x, y) be the edge with the smallest weigh. (Namely, e1 is the first edge chosen by Kruskal's algorithm.) Let G = (V , E ) be the graph obtained from G by merging x and y:
x and y becomes a single new vertex z in G . Namely V = V  {x, y} {z} c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 14 / 49 Optimal Substructure Property for MST Example
Optimal Substructure Property for MST Let G = (V, E) be a connected graph with edge weight. Let e1 = (x, y) be the edge with the smallest weigh. (Namely, e1 is the first edge chosen by Kruskal's algorithm.) Let G = (V , E ) be the graph obtained from G by merging x and y:
x and y becomes a single new vertex z in G . Namely V = V  {x, y} {z} e1 is deleted from G. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 14 / 49 Optimal Substructure Property for MST Example
Optimal Substructure Property for MST Let G = (V, E) be a connected graph with edge weight. Let e1 = (x, y) be the edge with the smallest weigh. (Namely, e1 is the first edge chosen by Kruskal's algorithm.) Let G = (V , E ) be the graph obtained from G by merging x and y:
x and y becomes a single new vertex z in G . Namely V = V  {x, y} {z} e1 is deleted from G. Any edge ei in G that was incident to x or y now is incident to z. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 14 / 49 Optimal Substructure Property for MST Example
Optimal Substructure Property for MST Let G = (V, E) be a connected graph with edge weight. Let e1 = (x, y) be the edge with the smallest weigh. (Namely, e1 is the first edge chosen by Kruskal's algorithm.) Let G = (V , E ) be the graph obtained from G by merging x and y:
x and y becomes a single new vertex z in G . Namely V = V  {x, y} {z} e1 is deleted from G. Any edge ei in G that was incident to x or y now is incident to z. The edge weights remain unchanged. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 14 / 49 Optimal Substructure Property for MST 2 d 3 c 5 4 4 G x a 3 e
1 2 d 5 3 4 c b 5 4 4 G' z a 3 4 2 b 5 1 2 y Optimal Substructure Property for MST
If T is a MST of G containing e1 , then T = T  {e1 } is a MST of G . c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 15 / 49 Outline 1 Greedy Algorithms Elements of Greedy Algorithms Greedy Choice Property for Kruskal's Algorithm 0/1 Knapsack Problem Activity Selection Problem Scheduling All Intervals 2 3 4 5 6 c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 16 / 49 Greedy Choice Property for Kruskal's Algorithm Let e1 , e2 , . . . , em be the edge list in the order of increasing weight. So e1 is the first edge chosen by Kruskal's algorithm. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 17 / 49 Greedy Choice Property for Kruskal's Algorithm Let e1 , e2 , . . . , em be the edge list in the order of increasing weight. So e1 is the first edge chosen by Kruskal's algorithm. Let Topt be an MST of G. By definition, the total weight of Topt is the minimum. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 17 / 49 Greedy Choice Property for Kruskal's Algorithm Let e1 , e2 , . . . , em be the edge list in the order of increasing weight. So e1 is the first edge chosen by Kruskal's algorithm. Let Topt be an MST of G. By definition, the total weight of Topt is the minimum. We want to show Topt contains e1 . c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 17 / 49 Greedy Choice Property for Kruskal's Algorithm Let e1 , e2 , . . . , em be the edge list in the order of increasing weight. So e1 is the first edge chosen by Kruskal's algorithm. Let Topt be an MST of G. By definition, the total weight of Topt is the minimum. We want to show Topt contains e1 . But this is not always possible. Recall that the MST of G is not unique. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 17 / 49 Greedy Choice Property for Kruskal's Algorithm Let e1 , e2 , . . . , em be the edge list in the order of increasing weight. So e1 is the first edge chosen by Kruskal's algorithm. Let Topt be an MST of G. By definition, the total weight of Topt is the minimum. We want to show Topt contains e1 . But this is not always possible. Recall that the MST of G is not unique. So we will do this: Starting fr...
View
Full
Document
This note was uploaded on 02/27/2012 for the course CSE 431/531 taught by Professor Xinhe during the Fall '11 term at SUNY Buffalo.
 Fall '11
 XINHE
 Algorithms

Click to edit the document details