Finding all subsets: one solution

In asking the reader to consider listing all subsets of four objects ${a, b, c, d}$, this author listed:

${}$,
${a}, {b}, {c}, {d}$
${a, b}, {a, c}, {a, d}, {b, c}, {b, d}, {c, d}$
${a, b, c}, {a, b, d}, {a, c, d}, {b, c, d}$
${a, b, c, d}$

The algorithm used to create this is as follows:

1. Start with $n + 1$ sets, number $0$ through $n$. The $i$th set starts with the first $i$ entries.

Thus, if we had five objects, ${v, w, x, y, z}$, I would start with

${}$, {v}, {v, w}, {v, w, x}, {v, w, x, y}, {v, w, x, y, z}$

We will call these starter sets.

Now, for each of these starter sets, perform the following algorithm:

2. Starting with the last entry, find the first entry that can be changed to the next value in the set, and then replace all subsequent entries that could not be moved (say there are $m$ of these), to the next $m$ entries.

3. Go back to the previous step until no entry can be moved.

For example, given the set ${1, 2, 3, 4, 5}$, and given ${1, 2, 3}$, we can move $3$ to $4$ to get ${1, 2, 4}$, and then we can move $4$ to $5$ to get ${1, 2, 5}$. At this point, starting at the back, the last entry that can be moved is $2$, which can be moved to $3$, thus we continue with ${1, 3, 4}$.

If we repeat this algorithm for each of the starter sets, then we will create all subsets.

For example, if w, then we will create all subsets.

For example, if we started with $26$ entries ${a, b, c, \ldots, z}$, we may end up with

${b, e, f, k, m, w}$

in which case, the next set is

${b, e, f, k, m, x}$

If we had

${b, e, f, k, m, w, x, y, z}$

we would move $m$ and move the last four back

${b, e, f, k, n, o, p, q, r}$

and if we had

${q, s, t, u, v, w, x, y, z}$

the next would be

${r, s, t, u, v, w, x, y, z}$

which would also be the last for subsets with nine entries out of twenty six.

As you can imagine, this might be very difficult to program.