Is there a good data structure for storing overlapping sets? Consider having multiple sets which can overlap in various ways and would like to store them in the memory and access efficient way.
Example:
A = {a, b, c, d}
B = {a, b, c}
C = {b, c, d}
D = {a, b, d, e, f}
Storage:
W = {e}
X = {b, c}
Y = {d}
Z = {a}
B = Z union X
A = B union Y
C = X union Y
D = A union W
x - (x & (x - 1))
. In most other cases, a hashtable/dictionary is most convenient, though sorted arrays/lists enable intersection and union in linear time via list merge and have lower space overhead. – j_random_hacker Feb 29 '20 at 23:06A lot of these sets are just a different set with a few (even one) additional items.
My end goal is to store these sets in the smallest possible memory.
– Alexander Weps Feb 29 '20 at 23:19