I'm trying to find a good recursive algorithm to print out the subsets of a set.
For example
size 5: gives the set {1,2,3,4,5} and the subsets off length 3 gives this output:
{5,4,3}
{5,4,2}
{5,4,1}
{5,3,2}
{5,3,1}
{5,2,1}
{4,3,2}
{4,3,1}
{4,2,1}
{3,2,1}
I've tried many things but it doesn't work. On the internet all the examples are with sets algorithms but I want to write my own, for learning purposes.
Could someone help me with this?
Kind regards,
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…