user235410
user235410

Reputation: 109

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

Upvotes: 0

Views: 254

Answers (1)

Henrik
Henrik

Reputation: 23324

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.

Upvotes: 1

Related Questions