How do I find next bit to change in a Gray code in constant time?

后端 未结 7 790
终归单人心
终归单人心 2020-12-25 08:59

I have a small 8-bit processor which has a N-to-M decoder on some output lines - eg, for the 5 to 32 bit case, I write 00101 and bit 5 changes state. The only interface to

7条回答
  •  时光取名叫无心
    2020-12-25 09:31

    "Algorithm L" on page 10 of Knuth, Donald E. "Generating all n-tuples." The Art of Computer Programming, Volume 4A: Enumeration and Backtracking, pre-fascicle 2a, October 15, 2004 seems ideal. Step L4 would be "change_state(j)" for your device.

提交回复
热议问题