Binary Codes & Error Detection
![Question 40, GATE 2006: Let h₃h₂h₁h₀ be the four-bit reflected Gray code of n, and g₃g₂g₁g₀ the Gray code of (n+1) mod 16. Minterm indices refer to the current Gray word h. Which next-bit function is correct? GateForum A includes minterm 3; GFG appears to print 5 in that position.
Options:
(A) g₀=Σm(1,2,3,6,10,13,14,15) [GateForum; GFG: 1,2,5,6,10,13,14,15]
(B) g₁=Σm(4,9,10,11,12,13,14,15)
(C) g₂=Σm(2,4,5,6,7,12,13,15)
(D) g₃=Σm(0,1,6,7,10,11,12,13)](../../assets/questions/CS-2006-Q40-1.webp)
![Question 40, GATE 2006: Let h₃h₂h₁h₀ be the four-bit reflected Gray code of n, and g₃g₂g₁g₀ the Gray code of (n+1) mod 16. Minterm indices refer to the current Gray word h. Which next-bit function is correct? GateForum A includes minterm 3; GFG appears to print 5 in that position.
Options:
(A) g₀=Σm(1,2,3,6,10,13,14,15) [GateForum; GFG: 1,2,5,6,10,13,14,15]
(B) g₁=Σm(4,9,10,11,12,13,14,15)
(C) g₂=Σm(2,4,5,6,7,12,13,15)
(D) g₃=Σm(0,1,6,7,10,11,12,13)](../../assets/questions/CS-2006-Q40-2.webp)
Answer & solution
Answer: C (no official key was published)
1. Use h(n)=n⊕(n>>1) and g=h((n+1) mod16). Enumerating n=0,...,15 gives the ON-set for g2, indexed by the present Gray word h, as{2,4,5,6,7,12,13,15}, exactly C.
2. As cross-checks, g0 has{0,1,6,7,10,11,12,13}, g1 has{1,2,3,6,10,13,14,15}, and g3 has{4,9,10,11,12,13,14,15}; the other options attach these sets to wrong output bits.
3. Teaching check: Gray-code minterm indices are the current Gray words, not the underlying binary n values. For example n=0 gives h=0000 and next g=0001, so the present-state index zero belongs to g₀’s ON set. This immediately distinguishes some mislabeled alternatives.