coverage - minimizing amount of sets

The problem:

You have a number of sets. Equal elements present in multiple sets. The task is to eliminate the sets all elements of which are covered by other sets in order to get a miniaml number of sets.

For ex, {1,5} {5,6} {6,7} can be reduced to {1,5} {6,7} as elements (5,6) present in the first and last sets.

[335 byte] By [valjoka] at [2007-10-1 7:56:09]
# 1
> You have a number of sets.No, I don't. You do. Do your own homework.
Adeodatusa at 2007-7-9 20:46:27 > top of Java-index,Other Topics,Algorithms...
# 2

[1] Thank you for sharing the experience.

[2] When you need quantum physics equations of electron in atom, do you invent them at home or ask from the Knowsphere? If I'm on a wrong forum I'll be happy pointed on a better one.

[3] You have failed your style not ending with ~Cheers.

valjoka at 2007-7-9 20:46:27 > top of Java-index,Other Topics,Algorithms...
# 3

> [1] Thank you for sharing the experience.

My turn to share.

>

> [2] When you need quantum physics equations of

> electron in atom, do you invent them at home or ask

> from the Knowsphere?

You're not asking for anything close to a quantum physics equation. If you were, then it should be easy to turn to any computer science book and find the algorithm you are looking for.

> If I'm on a wrong forum I'll be happy pointed on a better one.

You mean one which does your homework for you right?

rkippena at 2007-7-9 20:46:27 > top of Java-index,Other Topics,Algorithms...
# 4
Set cover in general is an NP-complete problem. However, if all of your sets are of cardinality 2 it can be solved efficiently using an algorithm for matching. If some of your sets are larger than 2, there are fairly effective approximations.
RadcliffePikea at 2007-7-9 20:46:27 > top of Java-index,Other Topics,Algorithms...
# 5

> [1] Thank you for sharing the experience.

You're welcome. Next time I might even throw in some sarcasm.

> [2] When you need quantum physics equations of

> electron in atom, do you invent them at home or ask

> from the Knowsphere? If I'm on a wrong forum I'll be

> happy pointed on a better one.

I invent my own. I'm afraid of heights, and tend to stay off giants' shoulders.

> [3] You have failed your style not ending with ~Cheers.

I disagree. I do not end with "~Cheers" when I don't like the thread/person posting/argument/some random thing or I forget to. That much is defined in my style and I have definitely stayed true to it.

On the same hand but a different finger, it's nice to be noticed :D

~Cheers

Adeodatusa at 2007-7-9 20:46:27 > top of Java-index,Other Topics,Algorithms...
# 6
> Set cover in general is an NP-complete problem.Thanks, this is exactly what I wanted to hear. Actually, the setes are arbitrary-sized; so, if i need an approximate algorithm where can I find it?
valjoka at 2007-7-9 20:46:27 > top of Java-index,Other Topics,Algorithms...
# 7
> If you were, then it should be> easy to turn to any computer science book and find> the algorithm you are looking for. rkippen, if I'm asking something in forum it is obviously because I do not know which book to turn.
valjoka at 2007-7-9 20:46:27 > top of Java-index,Other Topics,Algorithms...
# 8

There is a quick and dirty heuristic where you repeatedly choose the most "cost effective" set until you have covered all elements. "Cost effective" essentially means you choose the set that covers the most elements that haven't been covered yet. Not perfect, but its easy. There are other algorithms that may have better approximation bounds, look in your local university library for "Approximation Algorithms" by Vijay V. Vazirani. It discusses the set cover problem in several contexts. Or there's always google...

RadcliffePikea at 2007-7-9 20:46:27 > top of Java-index,Other Topics,Algorithms...