Checking a received byte for a parity error

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Checking a received byte for a parity error

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Even parity is agreed. The receiver gets 10110010. What is the result of the parity check?
A 4 ones, which is even: no error detected
B 4 ones, which is even: error detected
2. Odd parity is agreed. The receiver gets 01101100. What is the result of the parity check?
A 4 ones, which is not odd: error detected
B 4 ones, which is fine: no error detected
3. Even parity is agreed. The receiver gets 11100000. Which statement is correct?
A No error: 3 ones means the check passes
B Error detected: 3 ones is an odd count
4. Which bits does the receiver count when doing a parity check on a byte?
A All 8 bits, including the parity bit
B Only the 7 data bits, leaving out the parity bit
5. During transmission only the parity bit flips, from 0 to 1. The 7 data bits are unchanged. What does the receiver find?
A No error is detected, because the data bits are unchanged
B The count of 1s breaks the rule, so an error is detected

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
110110010 (even parity) AFour is an even count. Odd parity needs an odd count of 1s, so this byte fails the check and an error is detected.
211010100 (odd parity) B11100000 (even parity)
3A byte arrives under even parity with an odd number of 1s, so the receiver reports an error CFour 1s is an even count, which breaks the odd rule, so the check fails and an error is detected.
4The parity bit itself can be the bit that changed, and the check still fails D01100110 -> 11100110 (even)
5Odd parity: 10110100 has four 1s, so it passes EThe receiver must count the 1s in the whole byte, parity bit included. Ignoring the parity bit gives the wrong result.
6Count the 1s in the 7 data bits only and ignore the parity bit FFour 1s is an even count, so the even parity check passes and no error is detected.

Definitions

parity check

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
received ← 10110010 ones ← 4 IF ones MOD 2 = _ THEN OUTPUT "No error"
2.
received ← 11010110 ones ← 5 IF ones ___ 2 = 1 THEN OUTPUT "No error"
3.
IF ones MOD 2 = 0 THEN OUTPUT "No error" ____ OUTPUT "Error detected"
4.
received ← 10110011 ones ← 5 // parity bit included IF ones MOD 2 __ 0 THEN OUTPUT "Error"
5.
received ← 11010100 ones ← 4 IF ones MOD 2 = 0 THEN ______ "Error"

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A rule ← "odd"
B ones ← 4
C IF ones MOD 2 = 0 THEN
D OUTPUT "No error detected"
E ENDIF
Question 2
A rule ← "odd"
B ones ← COUNT_ONES(byte)
C IF ones MOD 2 = 1 THEN
D OUTPUT "Error detected"
E ELSE
F OUTPUT "Error detected"
Question 3
A byte ← "11010011"
B ones ← 4
C IF ones MOD 2 = 1 THEN
D OUTPUT "Error detected"
E ENDIF
Question 4
A sent ← "10101010"
B received ← "10101111"
C ones ← 5
D IF ones MOD 2 = 1 THEN
E OUTPUT "Error detected"
Question 5
A rule ← "odd"
B ones ← COUNT_ZEROS(received)
C IF ones MOD 2 = 1 THEN
D OUTPUT "No error detected"
E ELSE
F OUTPUT "Error detected"

Answer Key

Checking a received byte for a parity error
Section A: Quick Questions
Q1
A — 4 ones, which is even: no error detected
Q2
A — 4 ones, which is not odd: error detected
Q3
B — Error detected: 3 ones is an odd count
Q4
A — All 8 bits, including the parity bit
Q5
B — The count of 1s breaks the rule, so an error is detected
Section B: Match the Pairs
Q1
10110010 (even parity) → Four 1s is an even count, so the even parity check passes and no error is detected.
Q2
11010100 (odd parity) → Four 1s is an even count, which breaks the odd rule, so the check fails and an error is detected.
Q3
A byte arrives under even parity with an odd number of 1s, so the receiver reports an error → 11100000 (even parity)
Q4
The parity bit itself can be the bit that changed, and the check still fails → 01100110 -> 11100110 (even)
Q5
Odd parity: 10110100 has four 1s, so it passes → Four is an even count. Odd parity needs an odd count of 1s, so this byte fails the check and an error is detected.
Q6
Count the 1s in the 7 data bits only and ignore the parity bit → The receiver must count the 1s in the whole byte, parity bit included. Ignoring the parity bit gives the wrong result.
Section C: Definitions
Q1
parity check — The receiver counts the 1s in the whole received byte, parity bit included. If the count breaks the agreed even or odd rule, an error has occurred and is detected.
Section D: Fill in the Blanks
Q1
received ← 10110010 ones ← 4 IF ones MOD 2 = 0 THEN OUTPUT "No error"
Q2
received ← 11010110 ones ← 5 IF ones MOD 2 = 1 THEN OUTPUT "No error"
Q3
IF ones MOD 2 = 0 THEN OUTPUT "No error" ELSE OUTPUT "Error detected"
Q4
received ← 10110011 ones ← 5 // parity bit included IF ones MOD 2 <> 0 THEN OUTPUT "Error"
Q5
received ← 11010100 ones ← 4 IF ones MOD 2 = 0 THEN OUTPUT "Error"
Section E: Spot the Error
Q1
A — The check IF ones MOD 2 = 0 passes when the count of 1s is even, so the agreed rule is even parity. Line 1 should be rule ← "even".
Q2
D — With odd parity, an odd count of 1s means the byte passes the check. Line 4 should output "No error detected".
Q3
B — The byte 11010011 contains five 1s, not four. Line 2 should be ones ← 5, so the count matches the byte.
Q4
B — Only the last bit (the parity bit) changed, from 0 to 1. The received byte should be 10101011, which has five 1s. The broken line changes a data bit as well and gives six 1s.
Q5
B — A parity check counts the 1s in the received byte, not the 0s. Line 2 should be ones ← COUNT_ONES(received).