Possible Duplicate:
How to find all possible subsets of a given array?
I have to find all possible subset of a given array.Do you know any algorithm for this?
Possible Duplicate:
How to find all possible subsets of a given array?
I have to find all possible subset of a given array.Do you know any algorithm for this?
This is a long shot, but if you need a function to produce {},{1},{2},{3},{1,2},{2,3},{1,3},{1,2,3} from {1,2,3}. you could generate binary numbers from 0 to 2^count(array)-1 and select array items that correspond to binary digits in generated numbers.
000 -> {}
100 -> {1}
010 -> {2}
110 -> {1,2}
001 -> {3}
101 -> {1,3}
011 -> {2,3}
111 -> {1,2,3}
// left-side binary system aka lazy binary system