我正在尝试使用贪心算法实现集合覆盖问题的解决方案。
经典的贪心逼近算法是
input: collection C of sets over universe U , costs: C→R ≥0
output: set cover S
1. Let S←∅.
2. Repeat until S covers all elements:
3. Add a set s to S, where s∈C maximizes the number of elements in s not yet covered by set s in S, divided by the cost c(s).
4. Return S.
我有两个部分的问题:
一种。反向执行算法是否是有效算法,即
input: collection C of sets over universe U , costs: C→R ≥0
output: set cover S
1. Let S←C .
2. Repeat until there are no s∈S such that S-s=S (i.e. all elements in s are redundant):
3. Remove a set s from S, where s∈S minimises the number of elements in s, divided by the cost c(s).
4. Return S.
湾。问题的本质是很容易得到 C 并且冗余集的数量有限(<5) - 在这种情况下,这个去除算法会表现得更好吗?