Algorithm Design Paradigm-3 - 1
Algorithm Design Paradigm-3 - 1
Paradigm – 3_1
• Second Iteration:
𝐼 = {1,4,3,2}
Per new element cost for 𝑆1 = 𝐶𝑜𝑠𝑡(𝑆1)/|𝑆1 – 𝐼| = 5/0
Note that 𝑆1 doesn’t add any new element to 𝐼.
Per new element cost for 𝑆2 = 𝐶𝑜𝑠𝑡(𝑆2)/|𝑆2 – 𝐼| = 10/1
Note that 𝑆2 adds only 5 to 𝐼.
• The greedy algorithm provides the optimal solution for above example,
but it may not provide optimal solution all the time.
Greedy Set Cover: Example No Optimal Sol
• Example (Not Giving Optimal Solution):
𝑆1 = {1, 2}
𝑆2 = {2, 3, 4, 5}
𝑆3 = {6, 7, 8, 9, 10, 11, 12, 13}
𝑆4 = {1, 3, 5, 7, 9, 11, 13}
𝑆5 = {2, 4, 6, 8, 10, 12, 13}
• Let the cost of every set be same.
• The greedy algorithm produces result as {𝑆3, 𝑆2, 𝑆1}
• The optimal solution is {𝑆4, 𝑆5}