set intersection - finding the smallest array that intersects with a set of arrays -


say have 3 arrays - ['a', 'b'], ['b', 'c'] , ['d']. if create fourth array intersects these 3 arrays minimal number of elements array i'd ['b', 'd']. question is... how go finding array?

like ['a', 'b', 'c', 'd'] intersects arrays it's not minimal intersection - ['b', 'd'] is.

any ideas?

i don't have answer algorithm, true that, commenter amit wrote, np-complete problem. problem called hitting set problem, equivalent set cover problem.

if you're fine approximation, according wiki article, greedily picking elements hit arrays gets.


Comments

Popular posts from this blog

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -

apache - setting document root in antoher partition on ubuntu -

python - pip install -U PySide error -