I need an algorithm to find all of the subsets of a set where the number of elements in a set is n
.
S={1,2,3,4...n}
Edit: I am having trouble understanding the answers provided so far. I would like to have step-by-step examples of how the answers work to find the subsets.
For example,
S={1,2,3,4,5}
How do you know {1}
and {1,2}
are subsets?
Could SOmeone Make a Simple Function in c++ to find subsets of {1,2,3,4,5}