Finding SuperSet
#bit-manipulation
- 1 minutes read - 58 words
use bit manipulation to get all possible subset for a set
Given set = [1,2,3]
powerset size = pow(2, len([1,2,3]) → 8
consider each element as bit
then all possible sets are
000
001
010
011
etc
iterate through 0 → 7 [ 000 → 111]
1 means take 0 means leave and you have all the subsets