Hamming Codes and CRC: GATE ECE practice questions with solutions
This topic covers Hamming distance and bounds, Hamming encoding and syndrome decoding, linear codes and CRC division. The 15 original questions follow the GATE EC format: 9 MCQ, 2 MSQ and 4 NAT, from 5 easy, 7 medium and 3 hard.
Three ideas to know:
- The code rate is the fraction of transmitted bits that carry information.
- With position-based parity groups, the syndrome read as a binary number names the bad position.
- The parity part is the XOR of the P rows selected by the 1s in the data.
It helps GATE EC and ECE students revising Communications for the exam or a semester test. Helpful background: Block codes and Hamming distance. Start with the 5 easy questions, then work up to the 3 hard ones.
Related
Q.1
EasyMCQ1 mark
The code rate of a (7, 4) Hamming code is
Show answer and solutionHide answer and solution
Answer: (B)
Key idea: The code rate is the fraction of transmitted bits that carry information.
1. Rate = k/n. 2. k = 4 message bits and n = 7 code bits, so the rate is 4/7.
Common mistake: Taking the parity fraction (n − k)/n = 3/7, option (C).
You need: Block codes
Q.2
EasyMCQ1 mark
A block code has minimum Hamming distance 3. It can be used to
Show answer and solutionHide answer and solution
Answer: (B)
Key idea: Detection needs one extra unit of distance; correction needs a margin on both sides.
1. Detection of s errors needs d ≥ s + 1, so s = 2.
2. Correction of t errors needs d ≥ 2t + 1, so t = 1.
Common mistake: Using d ≥ s for detection gives 3 errors, and t = d − 1 = 2 for correction, option (C).
You need: Hamming distance
Q.3
EasyNAT1 mark
The Hamming distance between the words 1011010 and 1110011 is ______.
Numerical answer: type a number.
Show answer and solutionHide answer and solution
Answer: 3
Key idea: Hamming distance is the weight of the XOR of two words.
1. XOR bit by bit: 1⊕1, 0⊕1, 1⊕1, 1⊕0, 0⊕0, 1⊕1, 0⊕1 = 0101001.
2. The XOR has three 1s, so the distance is 3.
Common mistake: Counting the positions where the words agree (four) instead of the positions where they differ.
You need: Binary XOR
Q.4
EasyMCQ1 mark
A single-error-correcting Hamming code must protect 12 data bits. The minimum number of parity bits is
Show answer and solutionHide answer and solution
Answer: (C)
Key idea: The syndrome must point to every bit position, parity bits included, plus the no-error case.
1. The condition is 2ʳ ≥ k + r + 1. 2. r = 4: 16 ≥ 17 fails. 3. r = 5: 32 ≥ 18 holds.
4. So r = 5.
Common mistake: Checking 2ʳ ≥ k only gives r = 4 (16 ≥ 12), option (B).
You need: Hamming bound
Q.5
EasyMCQ1 mark
A single even-parity bit is appended to every 7-bit data word. At the receiver, this check can
Show answer and solutionHide answer and solution
Answer: (A)
Key idea: One parity bit has minimum distance 2: detection of single (odd) errors only.
1. An odd number of flips changes the parity of the word, so it is detected.
2. An even number of flips keeps the parity, so it is missed.
3. The check cannot tell which bit flipped, so it cannot correct.
Common mistake: Believing parity also locates the error and selecting (D).
You need: Parity check codes
Q.6
MediumMCQ1 mark
A (7, 4) Hamming code sends bits in positions 1 to 7 as p₁ p₂ d₁ p₃ d₂ d₃ d₄, with even parity: p₁ checks positions 1, 3, 5, 7; p₂ checks 2, 3, 6, 7; p₃ checks 4, 5, 6, 7. The word 0110101 is received with at most one error. The bit in error is at position
Show answer and solutionHide answer and solution
Answer: (D)
Key idea: With position-based parity groups, the syndrome read as a binary number names the bad position.
1. Check 1 (positions 1, 3, 5, 7): 0 + 1 + 1 + 1 = odd, s₁ = 1.
2. Check 2 (positions 2, 3, 6, 7): 1 + 1 + 0 + 1 = odd, s₂ = 1.
3. Check 3 (positions 4, 5, 6, 7): 0 + 1 + 0 + 1 = even, s₃ = 0.
4. Syndrome s₃s₂s₁ = 011 = 3.
5. Corrected word: 0100101.
Common mistake: Reading the syndrome bits in the reverse order, s₁s₂s₃ = 110 = 6, option (B).
You need: Hamming code decoding
Q.7
MediumNAT1 mark
A (7, 4) Hamming code is used over a binary symmetric channel with bit error probability 0.01, and the decoder corrects single errors. The probability that a block is decoded wrongly (two or more errors) is ______ (round to four decimal places).
Numerical answer: type a number.
Show answer and solutionHide answer and solution
Answer: 0.002 (accepted 0.002 to 0.0021)
Key idea: A single-error-correcting code fails only when two or more errors occur.
1. P(0 errors) = 0.99⁷ = 0.93207.
2. P(1 error) = 7 × 0.01 × 0.99⁶ = 0.06590.
3. P(fail) = 1 − 0.93207 − 0.06590 = 0.00203.
Common mistake: Counting any error as a failure, 1 − 0.99⁷ = 0.0679.
You need: Binomial probability, Hamming codes
Q.8
MediumMCQ2 marks
Using the (7, 4) Hamming code with positions p₁ p₂ d₁ p₃ d₂ d₃ d₄ and even parity (p₁ over positions 1, 3, 5, 7; p₂ over 2, 3, 6, 7; p₃ over 4, 5, 6, 7), the data d₁d₂d₃d₄ = 1011 is encoded as
Show answer and solutionHide answer and solution
Answer: (A)
Key idea: Each parity bit makes its group of four positions even.
1. Place data: d₁ = 1 at position 3, d₂ = 0 at 5, d₃ = 1 at 6, d₄ = 1 at 7. 2. p₁ = d₁ ⊕ d₂ ⊕ d₄ = 1 ⊕ 0 ⊕ 1 = 0. 3. p₂ = d₁ ⊕ d₃ ⊕ d₄ = 1 ⊕ 1 ⊕ 1 = 1. 4. p₃ = d₂ ⊕ d₃ ⊕ d₄ = 0 ⊕ 1 ⊕ 1 = 0.
5. Codeword: 0 1 1 0 0 1 1.
Common mistake: Using odd parity inverts all three parity bits and gives 1011011, option (B).
You need: Hamming code encoding
Q.9
MediumMSQ2 marks
Which of the following statements about binary linear block codes are correct?
One or more options are correct.
Show answer and solutionHide answer and solution
Answer: (A), (B) and (C)
Key idea: For linear codes, distances between codewords are weights of codewords.
1. Linearity gives closure under addition: (A).
2. Adding a codeword to itself gives 0, so (B) holds. 3. d(x, y) = weight(x ⊕ y), and x ⊕ y is a codeword, so (C) holds.
4. The Hamming code has codewords of weight 3, so some triple errors turn one codeword into another and go undetected: (D) false.
Common mistake: Thinking a distance-3 code detects three errors and selecting (D); it detects at most two for certain.
You need: Linear block codes
Q.10
MediumMCQ2 marks
A CRC uses the generator g(x) = x³ + x + 1 (bits 1011). For the message 1101011, three zeros are appended and the result is divided by 1011 in modulo-2 arithmetic. The remainder (the CRC bits) is
Show answer and solutionHide answer and solution
Answer: (C)
Key idea: Append as many zeros as the generator degree, divide modulo 2, and send the remainder after the message.
1. Dividend: 1101011000.
2. Modulo-2 long division by 1011 leaves the remainder 110.
3. Transmitted frame: 1101011110.
4. Check: 1101011110 divided by 1011 leaves 000.
Common mistake: Writing the remainder bits in reverse order gives 011, option (A), and the frame then fails its own check.
You need: Polynomial division over GF(2)
Q.11
MediumNAT2 marks
The number of codewords of weight 3 in the (7, 4) Hamming code is ______.
Numerical answer: type a number.
Show answer and solutionHide answer and solution
Answer: 7
Key idea: The weight distribution of the (7, 4) Hamming code is 1, 7, 7, 1 at weights 0, 3, 4, 7.
1. The 16 codewords have weights 0 (one word), 3 (seven words), 4 (seven words) and 7 (one word).
2. So there are 7 codewords of weight 3.
Common mistake: Counting every 7-bit pattern of weight 3, C(7, 3) = 35, instead of only codewords.
You need: Weight distribution of linear codes
Q.12
MediumMCQ2 marks
A receiver checks frames with the CRC generator 1011 (x³ + x + 1). The frame 1011110 is received. Dividing it by 1011 in modulo-2 arithmetic gives
Show answer and solutionHide answer and solution
Answer: (D)
Key idea: A valid CRC frame is exactly divisible by the generator.
1. 1011 XOR 1011 = 0000; bring down the next bits: 110.
2. The leading bit of 110 is under the degree, so no more subtraction is possible within 7 bits.
3. Remainder 110 is non-zero, so the frame is rejected.
Common mistake: Stopping after the first XOR gives 000 and accepting the frame, option (A), while bits 110 are still left.
You need: CRC checking
Q.13
HardMCQ2 marks
A systematic (7, 4) code has generator G = [I₄ | P], where the parity rows of P for data bits d₁ to d₄ are 110, 011, 111 and 101. The codeword for data 1001 is
Show answer and solutionHide answer and solution
Answer: (B)
Key idea: The parity part is the XOR of the P rows selected by the 1s in the data.
1. Data bits d₁ and d₄ are 1.
2. Parity = row 1 ⊕ row 4 = 110 ⊕ 101 = 011.
3. Codeword = data followed by parity: 1001011.
Common mistake: Using only the last selected row, 101, gives 1001101, option (A).
You need: Generator matrices
Q.14
HardNAT2 marks
For the systematic (7, 4) code with G = [I₄ | P] and parity rows 110, 011, 111 and 101, the minimum Hamming distance is ______.
Numerical answer: type a number.
Show answer and solutionHide answer and solution
Answer: 3
Key idea: For a linear code, d_min is the smallest non-zero codeword weight, found by checking combinations of rows.
1. Single data bits give weights 1 + 2, 1 + 2, 1 + 3, 1 + 2: so 3, 3, 4, 3.
2. Two data bits: the parity XOR of any two distinct rows has weight at least 1, giving weight at least 3.
3. Enumerating all 15 non-zero codewords gives a smallest weight of 3.
Common mistake: Taking the smallest weight among the parity rows alone (2), forgetting the data bit.
You need: Minimum distance of linear codes
Q.15
HardMSQ2 marks
A CRC uses the generator g(x) = x³ + x + 1 on frames of 7 bits (4 message bits and 3 CRC bits). Which error patterns within a frame are always detected?
One or more options are correct.
Show answer and solutionHide answer and solution
Answer: (A), (B) and (C)
Key idea: Guaranteed detection of all even-weight errors needs x + 1 as a factor of the generator.
1. g(x) has more than one term, so no single xⁱ is divisible by it: (A).
2. A burst of length at most 3 is xⁱb(x) with b of degree below 3, which g cannot divide: (B). 3. g(x) is primitive of degree 3, so it divides xʲ + 1 only for j a multiple of 7; within 7 bits j ≤ 6, so (C). 4. g(1) = 1, so x + 1 is not a factor; the weight-4 pattern (x + 1)g(x) = x⁴ + x³ + x² + 1 is missed, so (D) is false.
Common mistake: Assuming every CRC catches all even-weight errors and selecting (D).
You need: CRC properties, polynomials over GF(2)
Past GATE questions on this topic
- GATE 2024 EC, Q.47: CRC encoding (2 marks, MCQ)
- GATE 2026 EC, Q.63: Hamming code error probability (2 marks, NAT)