Gray code for all k element subset of {1,…,n}

我的未来我决定 提交于 2019-12-08 12:47:52

This isn't going to be a complete answer, but it's also not going to fit in a comment.

The relationship to gray code that you need is the mirroring. Every time gray code sets a new bit, all the bits below it progress backwards from that point on (until that bit is cleared or a bit above that reverses the reversal).

To reproduce this with your lexicographic ordering you need to invert the order in which you iterate through the remaining bits after each swap.

You might be able to implement this as an iterative transformation, taking your regular ordering and repeatedly reversing the order of the remaining bits every time you encounter a transition from 1 to 0.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!