Re: Generate All Subsets





Gaijinco wrote On 09/26/05 14:33,:
> [...]
> Then again, the answer is still unresolved: There is another way to
> construct all possible subsets?

Of course there are other ways, but your question is
about algorithms, not about C. If you find another way
and have questions about how to implement it in C, come
back and ask. (If you have questions about how to do it
in C++, ask in comp.lang.c++ instead.)

<off-topic>

Consider a recursive solution. First, it's easy to
generate all the subsets of a one-element set: they are
the empty set and the set containing only the single
element. Next, once you have a way to generate all the
subsets of an N-element set it's easy to generate all
the subsets of an (N+1)-element set: they are all the
given subsets "as is," plus those same subsets but with
the (N+1)st element added to each.

Remember, you asked only for "another way," not for
"another good way" ...

</off-topic>

--
Eric.Sosman@xxxxxxx

.



Relevant Pages