Gray Code is a binary numeral system where 2 successive values differ in only one bit. It is also known as the reflected binary code

Given n-bit gray code it’s easy to write (n + 1)-bit gray code

  1. Write down the 2-bit gray code (code in red)
  2. Write down the reflected code (shown in green)
  3. Put a ‘0’ at the beginning of each 2-bit Gray code and a ‘1’ at the beginning of each reflected code

Examples

1-bit Gray Code

0
1

2-bit Gray Code

00
01
11
10

3-bit Gray Code

000
001
011
010
110
111
101
100

Gray Code Simplification

For n > 2, it is difficult to take advantage of the Gray code when the function is represented using the truth table. This is because input patterns that differ in only 1 position can be far apart in the truth table