GATE Computer ScienceHardGATE CS (PYQ pattern)

Let g(x) = x XOR (x >> 1) be the 8-bit binary-reflected Gray encoding. What is the smallest k ≥ 1 such that applying g k times returns every 8-bit value to itself?

  1. A. 8
  2. B. 2
  3. C. 7
  4. D. 256

Correct answer: A. 8

Over GF(2), g = I + S with S the right shift, and S⁸ = 0. Then g^(2^j) = I + S^(2^j): g² = I + S², g⁴ = I + S⁴, g⁸ = I + S⁸ = I. g⁴ ≠ I because S⁴ ≠ 0 (e.g. 10000000 → g⁴ gives 10001000), so the order is exactly 8.

More Digital Logic questions

Exams that ask this topic