Bird
Raised Fist0

Given the Gray code sequence output for n=3: [0, 1, 3, 2, 6, 7, 5, 4] Which original binary number corresponds to the Gray code 5 in this sequence?

hard🔄 Reverse Engineer Q9 of Q15
Bit Manipulation - Gray Code
Given the Gray code sequence output for n=3: [0, 1, 3, 2, 6, 7, 5, 4] Which original binary number corresponds to the Gray code 5 in this sequence?
A7 (binary 111)
B4 (binary 100)
C3 (binary 011)
D6 (binary 110)
Step-by-Step Solution
Solution:
  1. Step 1: Recall Gray code to binary conversion

    Binary = Gray ^ (Gray >> 1) ^ (Gray >> 2) ... until shift is 0.
  2. Step 2: Convert Gray code 5 (binary 101) back to binary

    5 ^ (5 >> 1) = 5 ^ 2 = 7; further shifts do not change the result.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Gray code 5 corresponds to binary 7 [OK]
Quick Trick: Invert Gray code by iterative XOR with shifted versions [OK]
Common Mistakes:
MISTAKES
  • Confusing Gray code with binary directly
  • Incorrect bitwise inversion
Trap Explanation:
PITFALL
  • Candidates often forget how to invert Gray code to original binary number.
Interviewer Note:
CONTEXT
  • Tests deep understanding of Gray code encoding and decoding.
Master "Gray Code" in Bit Manipulation

3 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bit Manipulation Quizzes