Syllabus & Goals 3 min
Cambridge 2.2 · Methods of error detection Paper 1 · Computer Systems
By the end of this lesson you can:
- Explain why errors happen during transmission and why they must be detected.
- Set and check parity bits (odd and even), and use a parity block to locate and correct an error.
- Describe how a checksum and an echo check detect errors.
Textbook: Chapter 2, §2.2.1–2.2.2 (pp. 54–59) — the need for error checking; parity, checksum and echo checks.
Recap / Warm-Up 5 min
Lesson 2 showed that long parallel cables can deliver skewed bits. Lesson 1 showed that packets can go missing. Today: how does the receiver know something went wrong?
Quick starter
Count the 1-bits: 10110110. Is the count odd or even?
Reveal the answer
Five 1-bits — an odd number. Counting 1s is the whole idea behind parity.
Key Concept 14 min
1 · Why errors happen
When data is transmitted, it can be corrupted, lost or even gained. There are three main causes:
A person can often read a sentence with jumbled letters, like "Tihs is esay to raed". A computer cannot. If a word is not in its dictionary, or a byte is wrong, the data is useless. So every receiver must check data after transmission. Three methods do this: parity checks, checksum and echo check.

2 · Parity checks
A parity check is based on the number of 1-bits in a byte. Sender and receiver first agree the protocol: even parity (an even number of 1s) or odd parity (an odd number of 1s). One bit — usually the most significant (left-most) bit — is reserved as the parity bit. It is set to make the count of 1s fit the protocol.
The receiver recounts the 1s in every byte. If even parity was agreed but a byte has an odd number of 1s, the parity has changed, so a transmission error is flagged.
3 · The weakness of a single parity bit
If two bits change, the count can stay even (or stay odd). Then no error is flagged, even though the byte is wrong. And even when one error is flagged, the receiver cannot tell which bit is wrong.
4 · Parity blocks — find the bit, not just the byte
A block of bytes is sent. Parity is checked horizontally (each byte) and vertically (each bit column). The vertical parity bits form an extra parity byte, sent at the end; it also marks the end of the block. A wrong row and a wrong column cross at the exact bit that changed.
5 · Checksum
A checksum is an extra value sent at the end of a block of data:
6 · Echo check
Worked Example 12 min
(a) Set and check parity bits
| 7 data bits | Number of 1s | Even parity bit | Odd parity bit |
|---|---|---|---|
| 1011001 | 4 | 0 | 1 |
| 0110111 | 5 | 1 | 0 |
| 1110000 | 3 | 1 | 0 |
| 0000000 | 0 | 0 | 1 |
- Count the 1s in the 7 data bits. the parity bit only depends on this count.
- Even parity: if the count is already even, the bit is 0; if odd, it is 1.
- Odd parity is the opposite choice. the two protocols always give opposite parity bits.
- Checking a received byte under even parity: 10110110 has five 1s — odd, so an error is flagged. 01100110 has four 1s — accepted.
(b) Locate and correct an error in a parity block
Use the block drawn in the Key Concept (even parity agreed).
- Count the 1s in each byte (row). Bytes 1, 2, 3 and 6 have four; byte 5 has six. Byte 4 00001011 has 3 — odd ✗.this tells us which byte is wrong.
- Count the 1s in each column, including the parity byte. Every column totals 4, except bit 6, which totals 3 — odd ✗.this tells us which position is wrong.
- The error is where row 4 meets column 6. That bit arrived as 0.only one bit sits in both the bad row and the bad column.
- Flip it: byte 4 should be 00001111. Now row 4 has four 1s and column 6 has four 1s — both even ✓.always re-check both the row and the column after correcting.
(c) Calculate and verify a checksum
Agreed algorithm (example): add the byte values; the checksum is the remainder after dividing the total by 256. A block holds the bytes 150, 64, 200, 33 and 95.
- Sender adds the bytes: 150 + 64 + 200 + 33 + 95 = 542.
- 542 ÷ 256 = 2 remainder 30 (2 × 256 = 512; 542 − 512 = 30). Checksum = 30, sent after the block.the remainder keeps the checksum small enough to fit in one byte.
- Receiver gets 150, 66, 200, 33, 95 (the second byte was corrupted). Total = 544; 544 − 512 = 32.
- 32 does not match 30, so an error is detected and the receiver asks for the block to be re-sent.the receiver cannot tell which byte is wrong — only that the block is.
The parity check as an algorithm
Cambridge pseudocode
// Even parity bit for 7 data bits
DECLARE Bits : ARRAY[1:7] OF INTEGER
DECLARE Index : INTEGER
DECLARE Ones : INTEGER
DECLARE ParityBit : INTEGER
Bits[1] ← 1
Bits[2] ← 0
Bits[3] ← 1
Bits[4] ← 1
Bits[5] ← 0
Bits[6] ← 0
Bits[7] ← 1
Ones ← 0
FOR Index ← 1 TO 7
IF Bits[Index] = 1
THEN
Ones ← Ones + 1
ENDIF
NEXT Index
IF Ones MOD 2 = 0
THEN
ParityBit ← 0
ELSE
ParityBit ← 1
ENDIF
OUTPUT "Even parity bit is ", ParityBitThe same in Python (IDLE)
# Even parity bit for 7 data bits bits = [1, 0, 1, 1, 0, 0, 1] ones = 0 for bit in bits: if bit == 1: ones = ones + 1 if ones % 2 == 0: parity_bit = 0 else: parity_bit = 1 print("Even parity bit is", parity_bit)
Output
Even parity bit is 0
Try It Yourself 12 min
Goal: find the parity bit for each 7-bit value: 1101101 (even parity), 0000111 (odd parity), 1111111 (even parity).
Goal: odd parity was agreed. Which of these received bytes show an error? 11111111, 00010011, 10000000, 01101100. For one that passes, explain how it could still be wrong.
Goal: using the checksum algorithm from example (c), work out the checksum for the block 255, 255, 17. Then invent a different corrupted block that gives the same checksum — and explain what that shows about checksums.
Hint
Total first, then subtract multiples of 256. For the second part, change two bytes so that one goes up by the same amount the other goes down.
📝 Exam Practice 10 min
Put these parity-check statements into the correct order (1–5):
- A — the receiver checks the parity of each byte against the agreed protocol
- B — sender and receiver agree the parity protocol (odd or even)
- C — if a byte's parity is wrong, the receiver asks for the data to be re-sent
- D — the sender adds a parity bit to each byte
- E — the sender transmits the bytes, including the parity bits
Mark scheme
- Correct order: B, D, E, A, C.
- 4 marks for all correct; 3 marks for four in the right place; 2 marks for three; 1 mark for two.
Describe how a checksum is used to detect errors after data transmission.
Mark scheme
- The checksum is calculated from the block of data (before sending) (1).
- …using an algorithm agreed by sender and receiver (1).
- The checksum is sent with / at the end of the block (1).
- The receiver recalculates the checksum from the received block (1).
- The two checksums are compared; if different, an error has occurred / re-send is requested (1).
Any four.
Odd parity is used. One bit changed during transmission. Identify the byte and the bit in error, and give the corrected byte.
| Parity | Bit 2 | Bit 3 | Bit 4 | Bit 5 | Bit 6 | Bit 7 | Bit 8 | |
|---|---|---|---|---|---|---|---|---|
| Byte 1 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 0 |
| Byte 2 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
| Byte 3 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
| Byte 4 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| Parity byte | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 1 |
Mark scheme
- Byte 2 (it has two 1-bits — even, not odd) (1).
- Bit 5 (the column totals two 1-bits — even, not odd) (1).
- Corrected byte 2:
00011001(1).
Explain why an echo check is not a fully reliable method of error detection.
Mark scheme
- If the data sent back differs from the original, an error is known to have happened (1)…
- …but it is not known whether the error happened on the way to the receiver or on the way back (1).
Recap & Key Terms 3 min
Interference, packet problems and skew corrupt data. A parity bit makes each byte odd or even; a parity block finds the exact bit. A checksum is recalculated by the receiver. An echo check returns the data to the sender for comparison.
- Parity check
- A method to check data was transferred correctly, using even parity (an even number of 1-bits) or odd parity (an odd number of 1-bits).
- Parity bit
- A bit (0 or 1) added to a byte, usually in the most significant position, so the byte matches the agreed parity.
- Parity block
- A horizontal and vertical parity check on a block of data being transmitted.
- Parity byte
- An extra byte sent at the end of a parity block, made of the parity bits from the vertical check.
- Checksum
- A value calculated from a block of data and sent after it; the receiver recalculates it to check the data was not altered.
- Echo check
- Data is sent to a receiver and immediately sent back; the sender checks the returned data matches what was sent.
Homework 1 min
Task (≤ 15 min): Rory sends files to a server 100 m away. Identify two methods of error checking the system could use, and describe how each works. [6]
Model answer
- Parity check (1): sender and receiver agree odd or even parity; a parity bit is added to each byte (1); the receiver recounts the 1s and flags an error if the parity is wrong (1).
- Checksum (1): a value is calculated from each block with an agreed algorithm and sent with it (1); the receiver recalculates it and compares — a mismatch means re-send (1).
- Also accept echo check or ARQ with a correct description.