Introduction To Algorithms.
 §16. Greedy Algorithms (2)
                      2010 / 06




                                  1









    2
3














        3









    4


    

    

    





        5





    




        6










    7





    8





    9
10




     10
11




    



    



        12









    13
14




     14



    

    




        15





    16




    

    




        17


    

    

    




        18











    19








    



        20












    21






    

    

    


        22








    23






    

    



        24
Greedy (M,w)
1. A = φ
2. M.S   w   monotonically decreasing   sort
3. for x ∈ M.S
4. if A∪{x} ∈ M.I
5.     A = A∪{x}
6. return A




                                               25





    
    
    




        26









    27











    28











    29












    30
Greedy (M,w)
1. A = φ
2. M.S   w   monotonically decreasing   sort
3. for x ∈ M.S
4. if A∪{x} ∈ M.I
5.     A = A∪{x}
6. return A




                                               31











    32








    33









    34
35












    36













    37












    38











    39




    

    




        40












    41






    

    




        42







    43










    44









    45




    

    

    






        46




    

    

    




        47












    48
ai    1    2    3    4    5    6    7
    di    4    2    4    3    1    4    6
    wi   70   60   50   40   30   20   10









                                            49

Sec16 greedy algorithm no2