n be the set of activities to be selected assume f1

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: oice Property, we may assume the optimal solution O contains the job 1. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 34 / 49 Proof of Correctness By the Greedy Choice Property, we may assume the optimal solution O contains the job 1. Optimal Substructure Property Let S1 = {i S | si f1 }. (S1 is the set of jobs that are compatible with job 1. Or equivalently, the set of jobs that are not killed by job 1.) c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 34 / 49 Proof of Correctness By the Greedy Choice Property, we may assume the optimal solution O contains the job 1. Optimal Substructure Property Let S1 = {i S | si f1 }. (S1 is the set of jobs that are compatible with job 1. Or equivalently, the set of jobs that are not killed by job 1.) Let O1 = O - {1}. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 34 / 49 Proof of Correctness By the Greedy Choice Property, we may assume the optimal solution O contains the job 1. Optimal Substructure Property Let S1 = {i S | si f1 }. (S1 is the set of jobs that are compatible with job 1. Or equivalently, the set of jobs that are not killed by job 1.) Let O1 = O - {1}. Claim: O1 is an optimal solution of the job set S1 . c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 34 / 49 Proof of Correctness By the Greedy Choice Property, we may assume the optimal solution O contains the job 1. Optimal Substructure Property Let S1 = {i S | si f1 }. (S1 is the set of jobs that are compatible with job 1. Or equivalently, the set of jobs that are not killed by job 1.) Let O1 = O - {1}. Claim: O1 is an optimal solution of the job set S1 . If this is not true, let O1 be an optimal solution set of S1 . Since O1 is not optimal, we have |O1 | > |O1 |. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 34 / 49 Proof of Correctness By the Greedy Choice Property, we may assume the optimal solution O contains the job 1. Optimal Substructure Property Let S1 = {i S | si f1 }. (S1 is the set of jobs that are compatible with job 1. Or equivalently, the set of jobs that are not killed by job 1.) Let O1 = O - {1}. Claim: O1 is an optimal solution of the job set S1 . If this is not true, let O1 be an optimal solution set of S1 . Since O1 is not optimal, we have |O1 | > |O1 |. Let O = O1 {1}. Then O is a set of mutually compatible jobs in S, and |O | = |O1 | + 1 > |O1 | + 1 = |O|. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 34 / 49 Proof of Correctness By the Greedy Choice Property, we may assume the optimal solution O contains the job 1. Optimal Substructure Property Let S1 = {i S | si f1 }. (S1 is the set of jobs that are compatible with job 1. Or equivalently, the set of jobs that are not killed by job 1.) Let O1 = O - {1}. Claim: O1 is an optimal solution of the job set S1 . If this is not true, let O1 be an optimal solution set of S1 . Since O1 is not optimal, we have |O1 | > |O1 |. Let O = O1 {1}. Then O is a set of mutually compatible jobs in S, and |O | = |O1 | + 1 > |O1 | + 1 = |O|. But O is an optimal solution. This is a contradiction. Hence the claim is true. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 34 / 49 Proof of Correctness Jobs in S1 0 1 2 3 4 5 6 7 8 9 10 11 c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 35 / 49 Proof of Correctness Since the Optimal Substructure and Greedy Choice properties are true, we can prove the correctness of the greedy algorithm by induction. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 36 / 49 Proof of Correctness Since the Optimal Substructure and Greedy Choice properties are true, we can prove the correctness of the greedy algorithm by induction. Greedy algorithm picks the job 1 in its solution. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 36 / 49 Proof of Correctness Since the Optimal Substructure and Greedy Choice properties are true, we can prove the correctness of the greedy algorithm by induction. Greedy algorithm picks the job 1 in its solution. By the Greedy Choice property, there is an optimal solution that also contains the job 1. So this selection needs not be reversed. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 36 / 49 Proof of Correctness Since the Optimal Substructure and Greedy Choice properties are true, we can prove the correctness of the greedy algorithm by induction. Greedy algorithm picks the job 1 in its solution. By the Greedy Choice property, there is an optimal solution that also contains the job 1. So this selection needs not be reversed. The greedy algorithm delete all jobs that are incompatible with job 1. The remaining jobs is the set S1 in the proof of Optimal Substructure property. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 36 / 49 Proof of Correctness Since the Optimal Su...
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.

Ask a homework question - tutors are online