

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Total Marks = 20
Your assignment must be uploaded / submitted before or on June 11, 2012
Please view the assignment submission process document provided to you by the Virtual University.
Please note that your assignment will not be graded if:
Note: Material that is an exact copy from handouts or internet would be graded Zero marks. Your solution should consist of the material found through different sources and written in your own words.
Suppose that instead of always selecting the first activity to finish, we instead select the last activity to start that is compatible with all previously selected activities. Describe how this approach is a greedy algorithm, and prove that it yields an optimal solution.
The proposed approach: selecting the last activity to start that is compatible with all previously selected activities: is really the greedy algorithm but starting from the end rather than the beginning.
Another way to look at it is as follows. We are given a set S = { a 1 , a 2_... an_ } of activities, where ai = [ si , fi ] , and we propose to find an optimal solution by selecting the last activity to start that is compatible with all previously selected activities. Instead, let us create a set Sˊ = { aˊ 1 , aˊ 2_.. .aˊn_ }, where aˊi = [ fi , si ]. That is, aˊi is ai in reverse. Clearly, a subset of { ai 1 , ai 2_... aik_ } ⊆ S is mutually compatible if and only if the
docsity.com
corresponding subset { aˊi 1 , aˊi 2 ,... , aˊik } ⊆ Sˊ is also mutually compatible. Thus, an optimal solution for S maps directly to an optimal solution for Sˊ and vice versa.
The proposed approach of selecting the last activity to start that is compatible with all previously selected activities, when run on S , gives the same answer as the greedy algorithm from the text-selecting the first activity to finish that is compatible with all previously selected activities- when run on Sˊ. The solution that the proposed approach finds for S corresponds to the solution that the text’s greedy algorithm finds for Sˊ , and so it is optimal.
docsity.com