Re: Subsets from a set



stdazi@xxxxxxxxx wrote:
What i'd like to get is something like this

set A = {2,3,4,5}

subsets(A, 2) returns :

{2,3}, {2,4}, {2,5}, {3,5}, {4,5} .....


for subsets(A,n) you just need an array of size n. call it p. then a
subset S is

for(i=0;i<n;i++)
{
S[i] = A[p[i]];
}

to iterate over p, just notice that p[0] < p[1] < p[2] < ... < p[n-1]
with each p[i] between 0 and the size of A less 1.

.