Gray code for all k element subset of {1,…,n}
I am seeking for an algorithm which iterates through all k element subsets of an n element set. I do not want to generate all those subset explicitly. There is an easy algorithm to do this, namely sorting the corresponding bit vectors lexographically and then go from the current subset to the next one. Nevertheless, I seek for an algorithm which only switches 2 bits in each step. I have read that such a code is a called "gray-code" but I did not found an algorithm for my problem. Is there a straight forward implementation for this? This isn't going to be a complete answer, but it's also not