I am trying to create a method that will return all subsets of a set.
For example if I have the collection 10,20,30
I will like to get the following ou
This is a basic algorithm which i used the below technique to make a single player scrabble word solver (the newspaper ones).
Let your set have n
elements. Increment an integer starting from 0 to 2^n
. For each generater number bitmask each position of the integer. If the i
th position of the integer is 1
then select the i
th element of the set. For each generated integer from 0
to 2^n
doing the above bitmasting and selection will get you all the subsets.
Here is a post: http://phoxis.org/2009/10/13/allcombgen/