Updated Algorithm: There was a major flaw in my original presentation of the algorithm which could have impacted the results. I apologize for the same. The correction has been posted underneath.
The original algorithm posted had a major flaw in its working. I tried my best but could not get the desired accuracy in presenting the algorithm in pseudo code and/or Set Theory notation. I am thus posting python code, which has been tested and produces the desired results.
Note that my question, however, remains the same: What is the time complexity of the algorithm (assuming that powersets are already generated)?
# mps is a set of powersets; below is a sample (test case)
mps = [
[ [], [1], [2], [1,2] ],
[ [], [3], [4], [3,4] ],
[ [], [5], [6], [5,6] ]
]
# Core algorithm
# enumerate(mps) may not be required in languages like C which support indexed loops
len = mps.__len__()
for idx, ps in enumerate(mps):
if idx > len - 2:
break;
mps[idx + 1] = merge(mps[idx], mps[idx+1]) # merge is defined below
# Takes two powersets and merges them
def merge (psa, psb):
fs = []
for a in psa:
for b in psb:
fs.append(list(set(a) | set(b)))
return fs
Output: mps[-1] #Last item of the list
Running the above example will result in listing out the powerset of $\{1,2,3,4,5,6\}$.
len
is the number of powersets inmps
. Thus, 3 in our case. $\endgroup$