Given this input: [1,2,3,4]
I\'d like to generate the set of spanning sets:
[1] [2] [3] [4]
[1] [2] [3,4]
[1] [2,3] [4]
[1] [3] [2,4]
[1,2] [3] [4]
[1,3]
What about this? I haven't tested it yet, but I'll try it later…
I think this technique is called Dynamic Programming:
Take the first element [1]
What can you create with it? Only [1]
Take the second one [2]
Now you've got two possibilities: [1,2]
and [1] [2]
Take the third one [3]
With the first of number 2 [1,2]
one can create [1,2,3]
and [1,2] [3]
With the second of number 2 [1] [2]
one can create [1,3] [2]
and [1] [2,3]
and [1] [2] [3]
I hope it is clear enough what I tried to show. (If not, drop a comment!)