The powerset of {1, 2, 3} is:
{1, 2, 3}
{{}, {2}, {3}, {2, 3}, {1, 2}, {1, 3}, {1, 2, 3}, {1}}
Let\'s say I have a Set in Java:<
Set
One way without recursion is the following: Use a binary mask and make all the possible combinations.
public HashSet createPowerSet(Object[] array) { HashSet powerSet=new HashSet(); boolean[] mask= new boolean[array.length]; for(int i=0;i