Numericals Error Detection and Correction
Numericals Error Detection and Correction
Problem: Given the 7-bit data 1011001, determine the parity bit for even parity and provide the
transmitted code.
Solution:
Problem: For the 7-bit data 1100110, determine the parity bit for odd parity and provide the
transmitted code.
Solution:
Problem: A receiver gets the code 10011011 with even parity. Is there an error?
Solution:
4. Checksum: Calculation
Problem: Two 8-bit data segments 11011011 and 10101010 are transmitted. Compute the
checksum.
Solution:
Problem: A receiver gets data segments 11011011, 10101010, and checksum 01110001. Verify
the data.
Solution:
Problem: For data 1101011011 and divisor 1011, find the CRC remainder.
Solution:
Problem: Using the previous data and CRC, what is the transmitted frame?
Solution:
Problem: A receiver gets the frame 1101011011011 and uses divisor 1011. Is there an error?
Solution:
Solution:
Positions: p1 p2 d1 p3 d2 d3 d4.
Data: d1=1, d2=0, d3=1, d4=1.
Calculate parity bits:
o p1 for bits 1,3,5,7: p1 ⊕ d1 ⊕ d2 ⊕ d4 = 0.
o p2 for bits 2,3,6,7: p2 ⊕ d1 ⊕ d3 ⊕ d4 = 1.
o p3 for bits 4,5,6,7: p3 ⊕ d2 ⊕ d3 ⊕ d4 = 0.
Hamming code: 0111011.
Problem: A receiver gets the code 0110011. Detect and correct the error.
Solution:
1011
1101
1001
Solution:
10111
11010
10011
01101
12. Parity Check: Two-Dimensional Parity Error Detection
10111
11010
10011
01101
Is there an error?
Solution:
Problem: Compute the Internet checksum for the 16-bit words 1111000011110000 and
0000111100001111.
Solution:
Solution:
Q2. Given the data bits 1010101, what should the value of the parity bit be to achieve odd parity
for this 7-bit data?
A. 0
B. 1
C. Either 0 or 1 (odd parity does not constrain the parity bit uniquely)
D. No parity bit is needed for odd parity
Answer: B
Explanation: The data 1010101 has four 1s (which is even). For odd parity, the parity bit must be
1 to make the total number of 1s odd (five 1s).
Q3. In a two-dimensional parity check scheme (with parity bits for each row and each column of
a data block), which of the following is TRUE?
A. It can detect and correct a single-bit error in the data block.
B. It cannot detect two-bit errors at all.
C. It can correct any two-bit error as well.
D. It only detects errors but cannot pinpoint any error bit.
Answer: A
Explanation: 2D parity (parity per row and per column) can correct one-bit errors (by
identifying the intersecting row and column of the mismatch) and can also detect some multiple-
bit errors (though it cannot correctly fix multiple errors).
Q4. How is the standard Internet checksum typically computed for error detection (for example,
in TCP/IP)?
A. By treating the data as a polynomial and dividing by a generator polynomial.
B. By XOR-ing all bytes of data together.
C. By summing all data words (with wrap-around on overflow) and then using the one’s
complement of the sum.
D. By counting the number of bits set to 1 in the entire message.
Answer: C
Q5. Which of the following methods is an error-correcting code (as opposed to only error-
detecting)?
A. Even parity bit
B. Two-dimensional parity
C. Cyclic Redundancy Check (CRC)
D. Hamming code
Answer: D
Q6. If a cyclic redundancy check (CRC) uses a generator polynomial of degree r, how many
CRC check bits will be appended to the data?
A. r bits
B. r – 1 bits
C. r + 1 bits
D. 2r bits
Answer: A
Q7. A certain CRC polynomial has a degree of 4. It is guaranteed to detect all burst errors up to
what maximum length?
A. 4 bits
B. 5 bits
C. 15 bits
D. 8 bits
Answer: A
Explanation: A CRC generator of degree r will detect all burst errors of length ≤ r bits. (Most
CRCs also detect almost all bursts of length r+1 bits, with a few exceptions.)
Q8. Which of the following statements is FALSE about CRC error detection?
A. A properly chosen CRC can detect all single-bit errors.
B. CRCs can be designed to detect many multi-bit error patterns (such as all double-bit errors
within a certain length).
C. CRC is typically used for error detection in high-speed networks like Ethernet.
D. A CRC code can automatically correct a single-bit error in the received data.
Answer: D
Explanation: CRC is purely an error-detection code; it cannot correct errors by itself (it can only
detect them so that the frame can be retransmitted).
Q9. In an even parity scheme, if a receiver’s parity check for a frame fails (i.e., the parity bit plus
data has odd parity), what can be deduced?
A. No error occurred during transmission.
B. An even number of bits were flipped in transit.
C. An odd number of bits were flipped in transit.
D. The parity bit was corrupted, but the data bits are fine.
Answer: C
Q10. IEEE 802.3 Ethernet frames include a Frame Check Sequence for error detection. Which
technique do they use?
A. A single even parity bit at the end of the frame
B. A two-dimensional parity (longitudinal redundancy check)
C. A CRC (Cyclic Redundancy Check) code
D. A checksum based on one’s complement addition
Answer: C
Q11. Consider two 8-bit binary words: 01100101 and 10101001. If an Internet-style checksum is
computed on these two bytes, what 8-bit checksum value (one’s complement of the sum) would
be sent?
A. 00001110
B. 00001111
C. 11110000
D. 11111111
Answer: C
Explanation: Summing the bytes: 01100101 (0x65) + 10101001 (0xA9) produces 0x10E.
Adding the overflow carry back to the low 8 bits yields 0x0F. The one’s complement of 0x0F is
0xF0, which in binary is 11110000.
Q12. A data word of length 16 bits is to be encoded with a Hamming code (single-error
correction). How many parity bits are required?
A. 4
B. 5
C. 6
D. 8
Answer: B
Explanation: For Hamming code, parity bits p are chosen such that $2^p \ge m + p + 1$, where
m is data bits. For m = 16, the smallest p that satisfies $2^p \ge 16 + p + 1$ is p = 5 (since $2^4 =
16$ is not ≥ 21, but $2^5 = 32 \ge 22$). So 5 parity bits are needed.
Q13. A standard Hamming (7,4) code (7-bit code word with 4 data bits) has a minimum
Hamming distance of 3. What are its error detection and correction capabilities?
A. It can correct 1-bit errors and detect 2-bit errors.
B. It can correct 2-bit errors and detect 3-bit errors.
C. It can detect and correct 1-bit errors only (not 2-bit errors).
D. It can detect up to 3-bit errors but cannot correct any errors.
Answer: A
Q14. To detect up to 3-bit errors in any code word, what is the minimum Hamming distance the
coding scheme must have?
A. 3
B. 4
C. 5
D. 6
Answer: B
Explanation: To detect up to d bit errors, a code must have minimum Hamming distance d+1. To
detect up to 3-bit errors, distance 4 is required.
Q15. Given the dataword 1101 and generator polynomial 1011, which of the following is the
correct CRC remainder (CRC bits) that will be appended to the data?
A. 001
B. 011
C. 110
D. 101
Answer: A
Explanation: Dividing the binary polynomial 1101 (augmented with three 0s) by 1011 yields a
remainder of 001. Thus the transmitted code word would be 1101001 (data + CRC bits).
Solution:
Step 1: Count the number of 1s in the data 1010110. This data has four 1 bits.
Step 2: For even parity, the parity bit is chosen such that the total number of 1s (data bits
+ parity bit) is even. Currently there are 4 ones (even count) in the data. To keep the total
count even, the parity bit should be 0 (because adding 0 leaves the count of 1s unchanged
at 4, which is even).
Step 3: Thus, the parity bit = 0. The transmitted 8-bit codeword will be the original data
with this parity bit appended (often at the end or beginning as agreed). For example, if we
append it at the end, the codeword becomes 1010110**0**. This 8-bit sequence has four
1s (even), as required for even parity.
Q17. Parity Bit Calculation (Odd Parity): Now consider a 7-bit data string 1101011. You want
to use an odd parity scheme. Calculate the parity bit that should be added to achieve odd parity,
and give the resulting codeword. Show your steps clearly.
Solution:
Step 1: Count the 1s in 1101011. The data bits are: 1,1,0,1,0,1,1. The number of 1 bits =
5 (there are five ones).
Step 2: For odd parity, the total number of 1s in data + parity should be odd. The data
already has 5 ones, which is odd. To maintain odd parity, the parity bit in this case should
be 0 (because the count is already odd; adding a 1 would make it even).
Step 3: Therefore, the parity bit = 0. If we append this parity bit to the data, the 8-bit
codeword becomes 1101011**0**. This codeword has 5 ones in the data and 0 in parity
(parity bit is 0), total 5 ones, which is odd as required for odd parity.
Q18. Error Detection with Parity: Suppose a sender is using even parity for each transmitted
byte. The 8-bit codeword for some data (including the parity bit) is 01101001. (a) Verify that this
codeword has even parity. (b) Now assume a single-bit error occurs during transmission so that
the receiver gets 01101011. Show how the parity check at the receiver detects this error. (c) If
instead two bits of the codeword were corrupted (flip two bits in the original codeword to create
an example), explain and illustrate whether the parity scheme would catch it.
Solution:
Step 1: Verify even parity on the original codeword. The codeword 01101001 has the
bits: 0,1,1,0,1,0,0,1. Count the 1s: there are 4 ones. 4 is even, so indeed this codeword
satisfies even parity (the parity bit was set such that total ones are even). The receiver
checking this codeword would find no parity error if these bits arrived intact.
Step 2: Single-bit error scenario. Suppose a single bit flips during transmission. The
received byte is 01101011. Let’s identify the change: comparing to 01101001, it appears
the second-to-last bit (from the right) changed from 0 to 1. Now count the 1s in
01101011. The bits are 0,1,1,0,1,0,1,1, which contains 5 ones. 5 is odd. The receiver’s
even parity check will fail (it expects an even number of 1s if no error). Because the
parity check yields odd parity, the receiver knows an error has occurred. In this example,
a single-bit error is detected successfully by the parity mechanism.
Step 3: Two-bit error scenario. Now suppose two bits flip in the original codeword
01101001. For instance, flip the second bit and the last bit: the original was
0**1******...1, flipping second bit (1→0) and last bit (1→0) yields 00101000 as the
received byte. Count the 1s in this received sequence: 00101000 has 2 ones, which is
even. The parity check at the receiver would find an even number of 1s and would not
flag an error. However, in reality two bits have indeed been corrupted. This illustrates
that with a single parity bit, an even number of bit errors can fool the parity check.
Conclusion: Even parity can detect any odd number of flipped bits (1, 3, 5, …), but it
fails to detect an even number of bit errors because they can cancel out each other’s effect
on parity.
Q19. Two-Dimensional Parity Generation: Consider the following block of 12 data bits arranged
in a 3x4 matrix (3 rows, 4 columns):
1011
0110
1100
his data will be transmitted using a two-dimensional even parity scheme (i.e., adding a parity bit
to each row and each column). (a) Compute the parity bit for each of the 3 rows (make the total
of 1s in each row even). (b) Compute the parity bit for each of the 4 columns (make each
column’s 1s count even). (c) Present the complete augmented matrix (data plus parity bits),
including the additional row and column of parity.
Solution: We will calculate parity bits such that each row and each column has an even number
of 1s. Let’s label the rows R1, R2, R3 and columns C1, C2, C3, C4 for reference.
Step 1: Calculate row parity bits.
o Row 1: Data bits = 1 0 1 1. Count of 1s in R1 = 3 (which is odd). For even
parity, the parity bit must be 1 (making the total count 4).
o Row 2: Data bits = 0 1 1 0. Count of 1s in R2 = 2 (already even). The parity bit
for this row should be 0 (leaving the count even at 2).
o Row 3: Data bits = 1 1 0 0. Count of 1s in R3 = 2 (even). The parity bit is 0 (so
the count remains 2, even).
After this step, we can append these parity bits as an extra fifth column (Parity Column)
for each row:
Row1: 1 0 1 1 | 1
Row2: 0 1 1 0 | 0
Row3: 1 1 0 0 | 0
(The last column is the row parity bit; each row now has an even number of 1s.)
Step 2: Calculate column parity bits. Now include the row parity bits when counting column
1–4 totals? Actually, the column parity is usually computed only over the original data bits in
each column (and possibly we also consider the parity bits as part of an extra overall parity, see
below). We’ll compute parity for the original data columns C1–C4 across all rows:
Col 1: Data bits in C1 = {1, 0, 1} (from Row1, Row2, Row3). Number of 1s = 2 (even).
The parity bit for column 1 should be 0 (to keep it even).
Col 2: Bits in C2 = {0, 1, 1}. Number of 1s = 2 (even). Parity bit = 0.
Col 3: Bits in C3 = {1, 1, 0}. Number of 1s = 2 (even). Parity bit = 0.
Col 4: Bits in C4 = {1, 0, 0}. Number of 1s = 1 (odd). Parity bit = 1 (to make the count
even).
We will append these parity bits as an extra fourth row (Parity Row) at the bottom of the matrix:
(C1 C2 C3 C4 | ParityCol)
Row1 (data): 1 0 1 1 | 1
Row2 (data): 0 1 1 0 | 0
Row3 (data): 1 1 0 0 | 0
ParityRow: 0 0 0 1 |?
Here the ParityRow entries are the column parity bits we computed for C1..C4. For instance,
the ParityRow under C4 is 1, since column 4 had an odd count.
Step 3: Compute the overall parity bit (bottom-right corner). In a full two-dimensional
parity scheme, we typically include one more parity bit at the intersection of the parity row and
parity column (bottom-right corner). This bit is often chosen to ensure that the parity of the
parity bits themselves is consistent (making the entire block have even parity). One simple way:
compute the parity for the ParityRow or ParityCol themselves. In our partially filled parity
row/col matrix above, consider either the ParityRow or ParityCol counts:
If we look at the ParityRow values (0,0,0,1) there is one 1 (odd count). So to make parity
even in that row, the bottom-right corner bit should be 1.
Alternatively, check the ParityCol values (last column of each row parity): {1,0,0} has
one 1 (odd), so an overall parity of 1 at bottom-right also evens that out. This overall
parity bit in bottom-right ensures consistency from both perspectives.
Step 4: Present the final augmented matrix. Now we include the parity row and parity
column and the overall parity:
C1 C2 C3 C4 | ParityCol
R1 (data) : 1 0 1 1 | 1
R2 (data) : 0 1 1 0 | 0
R3 (data) : 1 1 0 0 | 0
ParityRow: 0 0 0 1 | 1
Answer for (c): The transmitted block including parity bits is:
1011|1
0110|0
1100|0
-----------
0001|1
Each row and each column (considering the full 4x4 data plus parity grid) now has an
even number of 1s.
Q20. 2D Parity Error Detection and Correction: Assume the transmitter sends a 3x4 data block
with two-dimensional parity (like in Q19, with parity bits added per row and column). The
receiver gets the following 4x5 block (3 data rows + 1 parity row, 4 data columns + 1 parity
column), with one bit corrupted in transit (the wrong bit is marked with * for clarity here):
1011|1
0110|0
1 1 *0 0 | 0
---------
0001|1
Describe how the receiver can detect that an error occurred and pinpoint which bit is in error.
Then correct the error and give the corrected data block.
Solution: In a two-dimensional parity scheme, the receiver will perform parity checks on each
row and each column of the received block to identify inconsistencies:
Step 1: Check each row’s parity. The receiver recalculates the parity of the bits in each
row (excluding the parity bit at the end of the row) and compares it to the received row
parity bit:
o Row 1: Data bits 1 0 1 1 have three 1s (odd). The parity bit in that row is 1,
which makes the total 1s count 4 (even). The parity is consistent (no error
detected in Row1).
o Row 2: Data bits 0 1 1 0 have two 1s (even). The parity bit is 0 (total remains 2,
even). Row2 parity is consistent (no error in Row2).
o Row 3: Data bits 1 1 *0 0. We count the 1s here: 1 1 0 0 would normally have
two 1s, but if one bit (marked *) is corrupted, we have to use what we received.
The received bits in Row3 are 1, 1, 0, 0 (assuming *0 means the third bit was
received as 0, possibly in error). Count of 1s = 2 (even). The parity bit for Row3
is 0 (as given). Even + parity 0 means the receiver expected an even count, and it
got an even count – actually, Row3 parity appears consistent in this case. (If the
error was a single bit in the data part, one of the row or column parities will be
off; it might be that our marked * is the error we suspect, but let's systematically
find it.)
o Parity Row (Row 4): This is the row of column parity bits. It has 0 0 0 1 and
the overall parity bit 1. Checking the parity row itself can indicate if the number
of column parity bits that are 1 is as expected. In the received Parity Row, there is
one 1 among the first four bits and the parity bit is 1, making two 1s (even), so the
parity row checks out. (Usually, the overall parity bit covers both the parity row
and parity column parity.)
From the row check alone, none of the row parity checks flagged an error in this
particular received block. (This suggests that perhaps the single-bit error might have
occurred in a parity bit rather than in the data? But let's check columns next, as 2D parity
will catch a single error in either data or parity bits.)
Step 2: Check each column’s parity. Now the receiver checks parity down each column
(excluding the parity row bit at the bottom of that column):
o Col 1: Received bits: 1, 0, 1 in data rows and parity bit 0 at bottom. Data bits
have two 1s (even), parity bit is 0 → column 1 is consistent (even parity).
o Col 2: Bits: 0, 1, 1 in data, parity bit 0 at bottom. Data bits have two 1s (even),
parity bit is 0 → column 2 consistent.
o Col 3: Bits: 1, 1, 0 in data (note: the third row third column bit is *0 as
received), parity bit at bottom is 0. The data bits in col3 as received have two 1s
(even), and the parity bit is 0, so column 3 appears consistent as well.
o Col 4: Bits: 1, 0, 0 in data, parity bit 1 at bottom. Data bits have one 1 (odd),
parity bit is 1 which makes total 2 ones (even). Column 4 parity is consistent.
Interestingly, in the given received block all row and column parity checks seem to be
formally consistent, which suggests no error would be detected — this is contradictory to
the assumption that one bit was corrupted. This means the example as provided (with a *
in Row3, Col3) might represent an error that was not caught by parity (which can happen
if the error is in the parity bits themselves in a coincident way).
To illustrate the typical process, let’s assume the * indicates an error and see how it
would normally be detected: If a single data bit were in error, one of the rows and one of
the columns would have an odd parity count, identifying the intersection as the error. For
example, if the bit at Row3, Col3 was supposed to be 1 but came as 0 (error), then:
o Row3’s actual data should have had 3 ones (odd) but we received 2 ones (even),
so Row3’s parity check would fail.
o Col3’s actual data should have had 3 ones (odd) but we received 2 (even), so
Col3’s parity check would fail. This would pinpoint the error at the intersection of
Row3 and Col3.
Let’s adjust the scenario to reflect a detectable single-bit error: Suppose the received
block was:
1011|1
0110|0
1 1 1 0 | 0 <- (Assume this third row third column should be 1 but got flipped to 1? Actually it
appears as 1, let's pick a different error)
---------
0001|1
(Concluding the example): Two-dimensional parity allows detection of a single-bit error and
identification of its position (since only that row and that column will have parity mismatches).
In the given block, if we assume the bit at Row3-Col3 was in error, we would have seen Row3
parity fail and Col3 parity fail, pinpointing the error at (3,3). Flipping that bit would correct the
data. The corrected data block (3x4) would then be the original data bits:
1011
0110
(Note: In the initially provided received block, the error as marked didn’t show up in parity checks, which
is a scenario of an undetected error – possibly a coincidental double error. Typically, a single error yields
a clear parity violation in one row and one column.)