All considered sets are subsets of a known finite set, for example {0..10 ^ 4}.
Let me call it N = 10 ^ 4. It is small enough and it will prove useful. Say you have S.
Logically means that you have an N * S matrix.
You will already have a set of sets. There are S-sets in this primary structure.
10 ^ 4 is small enough so that you can save a secondary data structure that stores for each value N the list of sets in which it is located. This structure is similar to transposing the primary structure. This can be a vector of length N, allowing you to search for a constant search of time to find a list of sets in which a certain value is located.
Now, when you add a new set, you can use this secondary structure to find which other sets are in each of their values. For example, we add a new set with values ββof 2.5, 10
new_set = {2,5,10}
The secondary structure tells us which sets they are in:
2 : {A,B,D} 5 : {B,D} 10 : {B}
We can combine and sort these three lists to get ABBBDD , which tells us not only what it imposes on it, but also about the size of the floors. Three nodes are shared with B, which means that our new set is a subset or equal to B. We share 1 node with A and two nodes with D. If it turns out that the total size of A is 1, then we now know that A is a subset our new multitude.
source share