This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ted activities Dashed lines are not selected 0 1 2 3 4 5 6 7 8 9 10 11 [1, 3) is the first interval selected. The dashed intervals [0, 4) and [2, 6) are killed because they are not compatible with [1, 3). c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 32 / 49 Example Input 0 1 2 3 4 5 6 7 8 9 10 11 After Sorting Solid lines are selected activities Dashed lines are not selected 0 1 2 3 4 5 6 7 8 9 10 11 [1, 3) is the first interval selected. The dashed intervals [0, 4) and [2, 6) are killed because they are not compatible with [1, 3). This problem is also called the interval scheduling problem.
c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 32 / 49 Proof of Correctness
Let S = {1, 2, . . . , n} be the set of activities to be selected. Assume f1 f2 fn . c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 33 / 49 Proof of Correctness
Let S = {1, 2, . . . , n} be the set of activities to be selected. Assume f1 f2 fn . Let O be an optimal solution. Namely O is a subset of mutually compatible activities and O is maximum. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 33 / 49 Proof of Correctness
Let S = {1, 2, . . . , n} be the set of activities to be selected. Assume f1 f2 fn . Let O be an optimal solution. Namely O is a subset of mutually compatible activities and O is maximum. Let X be the output from the Greedy algorithm. We always have 1 X. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 33 / 49 Proof of Correctness
Let S = {1, 2, . . . , n} be the set of activities to be selected. Assume f1 f2 fn . Let O be an optimal solution. Namely O is a subset of mutually compatible activities and O is maximum. Let X be the output from the Greedy algorithm. We always have 1 X. We want to show O = X. We will do this by induction on n. Greedy Choice Property
The activity 1 is selected by the greedy algorithm. We need to show there is an optimal solution that contains the activity 1. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 33 / 49 Proof of Correctness
Let S = {1, 2, . . . , n} be the set of activities to be selected. Assume f1 f2 fn . Let O be an optimal solution. Namely O is a subset of mutually compatible activities and O is maximum. Let X be the output from the Greedy algorithm. We always have 1 X. We want to show O = X. We will do this by induction on n. Greedy Choice Property
The activity 1 is selected by the greedy algorithm. We need to show there is an optimal solution that contains the activity 1. If the optimal solution O contains 1, we are done. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 33 / 49 Proof of Correctness
Let S = {1, 2, . . . , n} be the set of activities to be selected. Assume f1 f2 fn . Let O be an optimal solution. Namely O is a subset of mutually compatible activities and O is maximum. Let X be the output from the Greedy algorithm. We always have 1 X. We want to show O = X. We will do this by induction on n. Greedy Choice Property
The activity 1 is selected by the greedy algorithm. We need to show there is an optimal solution that contains the activity 1. If the optimal solution O contains 1, we are done. If not, let k be the first activity in O. Let O = O  {k} {1}. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 33 / 49 Proof of Correctness
Let S = {1, 2, . . . , n} be the set of activities to be selected. Assume f1 f2 fn . Let O be an optimal solution. Namely O is a subset of mutually compatible activities and O is maximum. Let X be the output from the Greedy algorithm. We always have 1 X. We want to show O = X. We will do this by induction on n. Greedy Choice Property
The activity 1 is selected by the greedy algorithm. We need to show there is an optimal solution that contains the activity 1. If the optimal solution O contains 1, we are done. If not, let k be the first activity in O. Let O = O  {k} {1}. Since f1 fk , all activities in O are still mutually compatible. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 33 / 49 Proof of Correctness
Let S = {1, 2, . . . , n} be the set of activities to be selected. Assume f1 f2 fn . Let O be an optimal solution. Namely O is a subset of mutually compatible activities and O is maximum. Let X be the output from the Greedy algorithm. We always have 1 X. We want to show O = X. We will do this by induction on n. Greedy Choice Property
The activity 1 is selected by the greedy algorithm. We need to show there is an optimal solution that contains the activity 1. If the optimal solution O contains 1, we are done. If not, let k be the first activity in O. Let O = O  {k} {1}. Since f1 fk , all activities in O are still mutually compatible. Clearly O = O . So O is an optimal solution containing 1.
c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 33 / 49 Proof of Correctness
By the Greedy Ch...
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