4c7 Tutorial1 Solutions
4c7 Tutorial1 Solutions
where mi are the message bits, i = 0, 1, 2, 3, and bi are the check bits, i = 0, 1, 2, 3.
(a) What are the parameters n and k? Find the generator matrix for the code.
(b) What is the minimum Hamming distance? How many errors can the code correct?
(c) Is the vector [1 0 1 0 1 0 1 0] a valid codeword?
(d) Is the vector [0 1 0 1 1 1 0 0] a valid codeword?
Solutions:
(a) n = 8, k = 4
⎛1 1 1 0 1 0 0 0⎞
⎜ ⎟
⎜1 0 1 1 0 1 0 0⎟
G =⎜
0 1 1 1 0 0 1 0⎟
⎜ ⎟
⎜1 1 0 1 0 0 0 1 ⎟⎠
⎝
Note: I assumed that the parity bits come at the beginning of the codeword. It would also have
been fine to swap the matrices I and P, making the parity bits come at the end of the codeword.
(b) All possible messages and corresponding codewords are tabulated below:
m c m c
0000 00000000 1000 11101000
0001 11010001 1001 00111001
0010 01110010 1010 10011010
0011 10100011 1011 01001011
0100 10110100 1100 01011100
0101 01100101 1101 10001101
0110 11000110 1110 00101110
0111 00010111 1111 11111111
⎛1 1 1 1 0 0 0⎞
⎜ ⎟
⎜1 0 1 0 1 0 0⎟
G =⎜
0 1 1 0 0 1 0⎟
⎜ ⎟
⎜1 1 0 0 0 0 1 ⎟⎠ .
⎝
Solutions:
m c m c
0000 0000000 1000 1111000
0001 1100001 1001 0011001
0010 0110010 1010 1001010
0011 1010011 1011 0101011
0100 1010100 1100 0101100
0101 0110101 1101 1001101
0110 1100110 1110 0011110
0111 0000111 1111 1111111
⎛1 0 0 1 1 0 1⎞
⎜ ⎟
(b) H = ⎜ 0 1 0 1 0 1 1 ⎟
⎜0 0 1 1 1 1 0⎟
⎝ ⎠
Solutions:
⎛1 0 1 1 1 0 0⎞
⎜ ⎟
(a) G = ⎜ 1 1 1 0 0 1 0 ⎟ , by swapping columns 1 and 7, columns 2 and 6, and columns 3
⎜0 1 1 1 0 0 1⎟
⎝ ⎠
and 5.
⎛1 0 0 0 1 1 0⎞
⎜ ⎟
⎜0 1 0 0 0 1 1⎟
(b) H = ⎜
0 0 1 0 1 1 1⎟
⎜ ⎟
⎜0 0 0 1 1 0 1 ⎟⎠
⎝
(d) dmin = 4.
(e) m = (1 0 1) , c = mG = (1 1 0 0 1 0 1) , cH T = (0 0 0 0 ) , so orthogonal.