Fast Data structure for finding strict subsets (from a given list)

Viewed 4121

I have a large set of sets e.g. {{2,4,5} , {4,5}, ...}. Given one of these subsets, I would like to iterate through all other subsets which are strict subsets of this subset. That is, if I am interested in set A, e.g. {2,4,5}, I want to find all sets B where the relative complement B / A = {}, the empty set. Some possibilities could be {2,4}, {2,5} but not {2,3}

I could of course search linearly and check each time, but am looking for an efficient data structure both for the larger set and the subset (if it matters). The number of subsets is typically in the 10s of thousands, but if it makes a difference I would be interested in cases where it could be in the hundreds of millions. The size of the subsets is typically in 10s.

I am programming in C++

Thanks

5 Answers
Related