algorithm - Obtaining the powerset of set with subsets of a certain size in Java -
i'm trying find efficient manner generate powerset of set has subsets of size k. have found answers of how generate powersets , powersets within range, i'm not sure how if wanted 1 size.
thanks!
create list containing elements of set.
create second list consisting of 1's , 0's,
- the total number of elements in list equal number of elements in set
- the number of 1's in list equal
k
for each permutation of second list, subset consists of elements first list corresponding entry in second list 1.
Comments
Post a Comment