We write numbers at k-maps in gray code in order to make adjacent columns or rows vary only in one bit i.e vary in one input variable only .When the required output variable is the same at two adjacent rows or columns, then the output variable is independent on the input variable that is different between these 2 rows (columns) .This originated form the boolean property :
karnaugh map is based on the adjascence between the blocks
each block shpould be adjascent to the one next to him (left right up down)
each block has an equivalent number that represents it in binary. 2 consecutive numbers should differ by only one bit.
example 00 01 11 10 (we replce 10 by 11)
without the adjascence the karnaugh map would never give the right answer
In the case of K-Map, we have difference of only 1-bit b/w adjacent cells.
Consider the case of first 2 cells: 00 01
In case(SOP) if we have 1 in both these cells then it will produce A'B'+A'B.
Which will give A' .
Because B+B'=1.
To utilise this concept of B+B'=1 easily we have Gray code in K-Map.
When we have a difference of 1 bit b/w two adjacent cells we can easily eliminate Redundant literals from the expression & then we can minimize our function which is the aim of K-Map !