Iβm looking for a sanity check and possible methods of speed up for filtering a long list of sets, some of which are subsets of others.
Specifically I have N = 120k to 200k sets of length < 10.
The sets contain Strings of StringLength 4 to 64, most commonly StringLength 5 to 8. The N sets are sorted by length, short to long, and the interior sets are sorted alphabetically. All sets are unique, but there are less than 1000 unique Strings.
I have devised an algorithm with shortcircuit logic:
- a storage array is initialized to size N
- counter k = 0
- an outer βiβ Do loop runs from 1 to N-1
- an inner βjβ While loop runs from i+1 to N or ceases if the ith set is a subset of the jth
- SubsetQ is only called if the ith set is shorter than the jth
- if no superset was found then the ith is placed in the storage array at position ++k
- at completion, the Nth set is placed in the storage array at ++k
Current runtimes are 12 to 18 minutes per 1000 βiβ; i.e. 2-3 days per set of N.