Reference no: EM132361058
Question :
As discussed in class, we can use the notion of parity to detect when an error occurs during transmission of data. International Standard Book Number (ISBN) codes use the same idea, called a check digit in this context. For this question we consider the older ISBN-10 standard of a lO-digit code. (Modern codes are longer.) An ISBN-10 code consists of nine code digits followed by a check digit, which ranges from zero to ten (but ten is represented by 'X'). The nine code digits uniquely identify a book and its publisher.
The check digit is computed as follows:
1. Set sum to O
2. Set mult to 10
3. For each of the 9 digits from left to right:
i. Multiply the digit by mult and add the result to sum
ii. Set mult to mult-l
4. The check digit is (11 - (sum mod 11)) mod 11, or (11 - sum % 11) x 11 in Python notation. Using a multiplier to compute the check digit has the pleasant property that swapping two digits or changing just one digit of a valid ISBN-10 results in an invalid ISBN-10. (You might notice a certain resemblance to one of the hash functions of Lab 7.)
a. What is the check digit needed to complete the ISBN-10 code 20 3356 542 _? Either show your arithmetic or show the code you used to obtain the answer (if you didn't write the code, explain where you got it).
b. Give an example of an invalid ISBN-10 code and explain why it is invalid.