ECE-C490 Computer Arithmetic

advertisement
ECE-C490 Security in Computing
Winter term 2005
Homework #4 Solutions
1. Design two circuits to implement a 2-dimensional parity check for 4-bit data
groups. One circuit should detect errors; the second should correct errors. How
many bit errors can be detected? Corrected? (single-, double-bit errors, etc).
This is actually a very basic circuit. Prior to transmitting code words, we line
align four code words as shown:
0101
0000
1101
1010
This gives us four columns and four rows, so we can generate a parity bit for each
row and column, and a final parity bit that’s generated from the “row parities” and
“column parities.” The parity bits are easily generated by the use of XORs; then,
once the code words have been transmitted, we re-generate a parity bit and
compare it to the one generated before transmission. If there is a difference, we
have detected an error.
The point of generating both row and column parity bits is so that we are able to
pinpoint the exact location of the error and correct it. For example, if we detect a
single bit error in row 1 and in column 2, we can easily trace that to a single bit in
our collection of code words, and simply flip the bit to correct the error.
Using this scheme, we can detect up to triple errors and reliably correct single bit
errors (successfully each time). It is possible that the circuit could correct more
than single bit errors, but it may do so unreliably (for example, by trying to
correct what it “thinks” is a triple bit error, the circuit may actually create a
quadruple error).
2. Prove the following statement is true:
for all a, b, c in J+, if (a,b) = 1, then (ac, b) = (c, b).
Proof:
(ac, b) | ac therefore
 
(ac, b) | (ac, bc)
(ac, b) | bc
next :
(ac, bc) (a, b)c
so
(ac, b) | c
and since
(ac, b) | b
we get
(ac, b) | (c, b)
but because we know :
(c, b) | ac
( c, b ) | b
it must also be true that
(c, b) | (ac, b)
So, in the course of this proof we have shown that (ac,b) | (c,b) and (c,b) | (ac, b).
This can only be true if (ac,b) = (c,b) – which is what we were trying to prove.
3. Use the Euclidean algorithm to determine the value of (525, 231).
525 = 2*231 + 63
231 = 3*63 + 42
63 = 1*42 + 21
42 = 2*21 + 0.
So (525, 231) = 21.
4. Find the number of divisors of 1260. What is the sum of these divisors?
1260
= 2 * 620
= 2 * 7 * 90
= 22 * 32 * 5 * 7
d(n) = (2+1)(2+1)(1+1)(1+1) = 36 divisors.
 (n) = {20 + 21 + 22}(30 + 31 + 32}(50 + 51}{70 + 71}
= {7}{13}{6}{8} = 4368.
5. Prove that the function  (n) generates the correct sum of divisors in the special
case where n is the product of two primes: p1 and p2.
If n is the product of two primes, then its prime factorization will consist of only
two numbers: p1 and p2. We know that the sum of divisors should be the sum of
the two primes + 1 + n, because aside of the two primes, n will have no other
factors besides itself and 1. Thus  (n) should be equal to 1 + p1 + p2 + n. In its
defined form, we will get
 (n)
= {p10 + p11}{p20 + p21}
= {1 + p1}{1 + p2}
= 1 + p1 + p2 + p1p2
= 1 + p1 + p2 + n
So we see that  (n) does generate the correct sum of divisors.
Download