4

I have a set of sets, for example

{
 {1, 2, 3},
 {1, 2},
 {2},
 {2, 4}
}

I want to find all sets which are not subsets of another set. For example, {2} and {1, 2} are both subsets of {1, 2, 3}, so my answer would just be {1, 2, 3} and {2, 4}. Let's call these "max sets".

There is a clear brute-force solution to this, where you check every pair of sets in $O(n^2)$ comparisons. Are there any known algorithms which do better than this?

Thoughts:

  • You can sort the list to avoid checking if a larger set is a subset of a smaller set, but this doesn't improve the asymptotic complexity.
  • Constructing a DAG out of the subset relations and performing a topological sort to find the max sets would still require examination of every pair.
  • You can eliminate a subset as soon as it is discovered, without checking it against the rest of the sets. I'm unable to derive any average-case complexity guarantees about this though, because an eliminated set may only have been a subset of a single max set.
Daniel M.
  • 141
  • 4

0 Answers0