in class exercise on Error detection

advertisement
CMSC 121-01 Intro to CS
Fall 2014
For this exercise, you may work in pairs. Put both names on the paper and hand in only one
copy. It will be assumed that both students contributed and understood.
Name(s): __________________________________________________________
0) a) For each of the following state whether an error is detected or not. Assume Odd
Parity.
Data + Parity Bit
00001111 1
Error detected? (yes or no)
11101111 0
10101010 0
01110111 0
10001000 1
b) For each of the following state whether an error is detected or not. Assume Even
Parity.
Data + Parity Bit
00001101 1
Error detected? (yes or no)
11110111 0
10011011 0
01010101 0
10101000 1
c) Assuming Odd Parity, what should the parity bit be for each of these data?
01010000
11100000
00110011
CMSC 121-01 Intro to CS
Fall 2014
1) Evaluate the following expressions:
23 mod 10
25 mod 9
23 mod 7
117 mod 3
50 mod 7
100 mod 9
32 mod 2
2) Recall that a simplistic check digit scheme is to add up all of the digits of the data.
Then, the check digit is that sum mod 10.
a) What would be the check digit for each of the following data:
23909
3952249
b) For each of the following, is an error detected (the check digit is at the end):
541796
56455723
CMSC 121-01 Intro to CS
Fall 2014
3) Recall that UPC codes have 12 digits. The error checking scheme is as follows.
Compute:
SUM = 3 * (1st digit + 3rd digit + 5th digit + 7th digit + 9th digit +
11th digit) + (2nd digit + 4th digit + 6th digit + 8th digit +
10th digit)
Valid UPC codes are such that (SUM + 12th digit) mod 10 = 0.
Are each of the following valid UPC codes?
036000258448
044000230391
038900029708
What would the 12th digit be of the following UPC code to make it valid?
13532489724_
CMSC 121-01 Intro to CS
Fall 2014
4) US Postal Money orders. Money orders have an 11 digit number. Their use of a
check sum is as follows:
SUM = sum of first 10 digits.
The number is valid if 11th digit = SUM mod 9.
(In a situation like this, the 11th digit is sometimes called the “check digit”.)
Is each of the following a valid number for a US Postal Money order?
32098713480
98712355637
What would the 11th digit be in order for the following money order number to be valid?
3413547892_
Download