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

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

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