0% found this document useful (0 votes)
10 views

Lecture 15 1

Uploaded by

Piyu Srivastava
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Lecture 15 1

Uploaded by

Piyu Srivastava
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Most computers do use linear congruential generators to generate

pseudorandom numbers. Often, a linear congruential generator with


increment c = 0 is used. Such a generator is called a pure multiplicative
generator. For example, the pure multiplicative generator with modulus
231 − 1 and multiplier 75 = 16,807 is widely used. With these values it can
be shown that 231 − 2 numbers are generated before repetition begins.

Check Digits
Congruences are used to check for errors in digit strings. A common
technique for detecting errors in such strings is to add an extra digit at the
end of the string. This final digit, or check digit, is calculated using a
particular function. Then, to determine whether a digit string is correct, a
check is made to see whether this final digit has the correct value.
Parity Check Bits
Digital information is represented by bit string, split into
blocks of a specified size.

Before each block is stored or transmitted, an extra bit,


called a parity check bit, can be appended to each block.

The parity check bit 𝑥𝑛+1 for the bit string 𝑥1 𝑥2 , , , 𝑥𝑛 is


defined by 𝑥𝑛+1 = 𝑥1 + 𝑥2 + ⋯ + 𝑥𝑛 𝑚𝑜𝑑 2

It follows that 𝑥𝑛+1 is 0 if there are an even number of 1


bits in the block of n bits and it is 1 if there are an odd
number of 1 bits in the block of n bits. When we examine
a string that includes a parity check bit, we know that
there is an error in it if the parity check bit is wrong.
However, when the parity check bit is correct, there still
may be an error. A parity check can detect an odd number
of errors in the previous bits, but not an even number of
errors.

Example 1: Suppose we receive in a transmission the bit


strings 11101101 and 10010010, each ending with a parity
check bit. Should we accept these bit strings as correct?

Solution: Before accepting these strings as correct, we


examine their parity check bits. The parity check bit of
the first string is 1.
𝑥𝑛+1 = 𝑥1 + 𝑥2 + ⋯ + 𝑥𝑛 𝑚𝑜𝑑 2
𝑥8 = 𝑥1 + 𝑥2 + ⋯ + 𝑥7 𝑚𝑜𝑑 2
𝑥8 = 1 + 1 + 1 + 0 + 1 + 1 + 0 𝑚𝑜𝑑 2 ≡ 1 (𝑚𝑜𝑑 2)
the parity check bit is correct.
The parity check bit of the second string is 0. We find that
𝑥8 = 𝑥1 + 𝑥2 + ⋯ + 𝑥7 𝑚𝑜𝑑 2
𝑥8 = 1 + 0 + 0 + 1 + 0 + 0 + 1 𝑚𝑜𝑑 2 ≡ 1 (𝑚𝑜𝑑 2)
so the parity check is incorrect.

We conclude that the first string may have been


transmitted correctly and we know for certain that the
second string was transmitted incorrectly. We accept the
first string as correct (even though it still may contain an
even number of errors), but we reject the second string.
Example 2: Retail products are identified by their
Universal Product Codes (UPCs). The most common form
of a UPC has 12 decimal digits: the first digit identifies
the product category, the next five digits identify the
manufacturer, the following five identify the particular
product, and the last digit is a check digit.

The check digit is determined by the congruence


3𝑥1 + 𝑥2 + 3𝑥3 + 𝑥4 + 3𝑥5 + 𝑥6 + 3𝑥7 + 𝑥8 + 3𝑥9 + 𝑥10 +
3𝑥11 + 𝑥12 ≡ 0 𝑚𝑜𝑑 10

(a) Suppose that the first 11 digits of a UPC are


39757323104. What is the check digit.
(b) Is 041331021641 a valid UPC?
Solution : (a)
The check digit is determined by the congruence
3𝑥1 + 𝑥2 + 3𝑥3 + 𝑥4 + 3𝑥5 + 𝑥6 + 3𝑥7 + 𝑥8 + 3𝑥9 + 𝑥10 +
3𝑥11 + 𝑥12 ≡ 0 𝑚𝑜𝑑 10

(b) To check whether 041331021641 is valid, we insert the


digits into the congruence these digits must satisfy. This
gives 3 · 0 + 4 + 3 · 1 + 3 + 3 · 3 + 1 + 3 · 0 + 2 + 3 · 1 + 6 +
3 · 4 + 1 ≡ 0 + 4 + 3 + 3 + 9 + 1 + 0 + 2 + 3 + 6 + 12 + 1 ≡
4 ≢ 0 (mod 10). Hence, 041331021641 is not a valid UPC
Example 3: All books are identified by an International
Standard Book Number (ISBN-10), a 10-digit code
𝑥1 , 𝑥2 , … , 𝑥10 , assigned by the publisher. (Recently, a 13-
digit code known as ISBN-13 was introduced to identify a
larger number of published works) An ISBN-10 consists of
blocks identifying the language, the publisher, the number
assigned to the book by its publishing company, and
finally, a check digit that is either a digit or the letter X
(used to represent 10). This check digit is selected so that
𝑥10 = σ9𝑖=1 𝑖𝑥𝑖 (𝑚𝑜𝑑 11)
or equivalently, so that σ10 𝑖=1 𝑖𝑥𝑖 ≡ 0(𝑚𝑜𝑑 11)

(a) The first nine digits of the ISBN-10 of the sixth edition
of this book are 007119008. What is the check digit?
(b) Is 084930149X a valid ISBN-10?
To see whether 084930149X is a valid ISBN-10, we see if

σ10
𝑖=1 𝑖𝑥𝑖 ≡ 0(𝑚𝑜𝑑 11)

We see that 1 · 0 + 2 · 8 + 3 · 4 + 4 · 9 + 5 · 3 + 6 · 0 + 7 ·
1 + 8 · 4 + 9 · 9 + 10 · 10 = 0 + 16 + 12 + 36 + 15 + 0 + 7 +
32 + 81 + 100 = 299 ≡ 2 ≢ 0 (mod 11). Hence, 084930149X
is not a valid ISBN-10.

You might also like