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.
精彩评论