Generating sequence of binary strings with k ones where next string differs in two digits

Viewed 2575

I am wondering about algorithm generating sequence of binary strings of length n with k ones where next string differs in two digits.

For example:

11100
11010
11001
10101
10110
10011
00111
01011
01101
01110
11100

Of course, there must be used all n \choose k binary strings.

3 Answers
Related