Is there an algorithm that is capable of generating a complete power set by only removing or adding one element in each step? I'd like it to avoid duplicates, but ordering isn't important. I've tried iterating over a set with four elements looking for a pattern that can be repeated to a larger set. I've found a dozen paths, but they seem to be random. Any help would be greatly appreciated.
Example with {x, y, z}: {} {x} {x, y} {y} {y, z} {z} {x, z} {x, y, z}
Starting with an empty set, every subsequent set is built by either adding or removing one element. I'd like to do this with larger sets predictably.
A set of elements can be thought of equivocally as the binary string problem. Suppose your set is finite, with cardinality $n$. We know then that the power set has cardinality $2^{n}$. So set up a binary vector with $n$ elements. If there is a $1$ for a component, then the element is in the subset. Otherwise, it isn't.
Consider the set $\{A, B, C\}$.
The power set can be generated by the binary vectors, simply by counting in binary: $$ (0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1) $$