What is the best algorithm to find the sets in a finite collection of sets that are a subset of a specific set?
For example, if
A = {1, 2}
B = {2, 3, 4}
C = {3, 5}
D = {6}
and X = {1, 2, 3, 5}
Then, A and C are subsets of X.
Is there an algorithm that I could do this in linear time complexity?
Implementation Note: The members of the sets are generally from a very limited range, therefore, it could be a good idea to use C++ bitset to implement the algorithm. Couldn't it?
Edit: The number of sets in the collection is generally very greater than The number of elements in X (in the example). Is there a way to do this linear in terms of the number of elements in X? Probably using hash or something?