Data Security, Integrity and Ethics: Question 3
Syllabus 6.2
StoreForward Ltd assigns each item in its warehouse a 4-digit stock number. A check digit is then calculated and appended to create a 5-digit stock code, using the following algorithm:
- multiply the 1st digit of the stock number by 7, the 2nd digit by 5, the 3rd digit by 3, and the 4th digit by 2
- add these four results together to give a weighted sum
- calculate the remainder when the weighted sum is divided by 11, using integer division
- this remainder becomes the check digit, appended as the 5th (final) digit of the new stock code
For example, stock number 1234 gives a weighted sum of (1 x 7) + (2 x 5) + (3 x 3) + (4 x 2) = 7 + 10 + 9 + 8 = 34. Dividing 34 by 11 using integer division gives a remainder of 1 (since 11 x 3 = 33), so the check digit is 1 and the new stock code is 12341.
(a) A new item has the stock number 4213. Calculate the check digit for this stock number, showing your working, and state the new 5-digit stock code. [2]
(b) A warehouse worker needs to enter the stock code 42133 into the system, but mistypes it as 42163. Use the check-digit algorithm to determine whether the system would accept or reject the code 42163, showing your working. [2]
(c) A different data integrity check, even parity, is used whenever a byte of data is transmitted across StoreForward's network, with the leftmost bit of each byte reserved as the parity bit. State what is meant by even parity, and determine the correct parity bit for the 7-bit data value 1011001. [2]
(d) State one limitation of a simple even parity check, giving an example of a situation in which it would fail to detect an error. [1]
Show worked solution Hide worked solution
Worked solution
Part (a): Calculating the check digit for stock number 4213
Multiply each digit by its assigned weight (7, 5, 3, 2 for digits 1 to 4):
digit: 4 2 1 3
weight: 7 5 3 2
product: 28 10 3 6
Weighted sum = 28 + 10 + 3 + 6 = 47.
Divide by 11 using integer division: 11 x 4 = 44, which is the largest multiple of 11 not exceeding 47, so the remainder is 47 - 44 = 3.
Check digit = 3. New 5-digit stock code = 42133.
[2 marks]: [1] for the correct weighted sum (47), [1] for the correct check digit (3) and stated code (42133).
Part (b): Checking the mistyped code 42163
The worker entered 42163, not the correct 42133. The 4th digit has changed from 3 to 6. To check it, recompute the weighted sum using the four digits that were actually entered (4, 2, 1, 6), then compare the result to the check digit that was actually entered (the final digit, 3):
digit: 4 2 1 6
weight: 7 5 3 2
product: 28 10 3 12
Weighted sum = 28 + 10 + 3 + 12 = 53.
53 MOD 11: 11 x 4 = 44 is the largest multiple of 11 not exceeding 53, so the remainder is 53 - 44 = 9.
The recalculated check digit (9) does not match the check digit that was entered (3), so the system rejects the code 42163. The check digit has successfully detected the transcription error.
[2 marks]: [1] for the correct recalculated weighted sum/remainder (53, remainder 9) using the digits actually entered, [1] for the correct conclusion (rejected, since 9 does not equal 3).
Part (c): Even parity and the parity bit
Even parity means that every byte transmitted must contain an even total number of 1-bits, counting the parity bit itself as one of the bits in that total. The sender sets the parity bit to whichever value (0 or 1) makes this total even; the receiver then checks that the total is still even.
Counting the 1-bits in the data value 1011001:
1 0 1 1 0 0 1 -> four 1-bits (positions 1, 3, 4 and 7)
Four is already an even number, so the parity bit must be 0 (adding a 1 would make the total five, an odd number, which would break even parity).
Full transmitted byte (parity bit leftmost): 01011001.
[2 marks]: [1] for correctly stating that even parity requires the total number of 1-bits, including the parity bit, to be even, [1] for the correct parity bit (0).
Part (d): A limitation of simple parity checking
A parity check only detects errors that change the total count of 1-bits from even to odd (or vice versa). That is, an odd number of bit errors. If an even number of bits are altered, the total number of 1-bits changes by an even amount, so the parity of the byte is unchanged and the error goes undetected.
For example, if both bit 3 and bit 4 of 1011001 were corrupted during transmission, flipping from 1 to 0, the data would become 1000001. The number of 1-bits falls from four to two, still an even number, so the parity bit would still appear correct, even though two bits of data are now wrong.
[1 mark] for correctly identifying that an even number of bit errors (e.g. two bits changing) goes undetected, with a valid supporting example.
Final answers
- (a) Check digit = 3; new stock code = 42133.
- (b) Weighted sum = 53, remainder = 9, which does not match the entered check digit 3, so 42163 is rejected.
- (c) Even parity: total 1-bits (including the parity bit) must be even; parity bit = 0; byte = 01011001.
- (d) A parity check cannot detect an even number of bit errors, e.g. two bits flipping leaves the total number of 1-bits, and so its evenness, unchanged.