开发者

Minimal grouping algorithm

I have a set of values, each value has a possible group. The value can ve repeating but in different group.

What will be an optimal algorithm to get minimum number of groups

A sample set: (12, group b) (38, group a) (12, group a)

Desired outcome: (38, group a) (12, group a开发者_运维问答)

(only one group is used)

-- edit: I need an algorithm to find minimum number of groups from a set like the sample above. If i would have a bad algorithm it will select (12, group b) (38, group a) This is 2 groups for the same values instead of using one, not what i want


If I understand the question correctly, this is the Set cover problem

The greedy algorithm as described in the link starts with group a and then terminates, as this already covers all.

Note that in general it yields only an approximation to the optimal solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜