CMPS 2433 – Coding Theory Chapter 3
-
Upload
fiona-buckley -
Category
Documents
-
view
45 -
download
0
description
Transcript of CMPS 2433 – Coding Theory Chapter 3
DR. RANETTE HALVERSONDEPARTMENT OF COMPUTER SCIENCE
MIDWESTERN STATE UNIVERSITY
CMPS 2433 – Coding TheoryChapter 3
2
SECURITYAccurac
y
The Code Book, Simon SinghPublic-key cryptographyNumber theoryCodes & Error-Correcting Codes
Cryptography - Coding
Even/Odd ParityEach byte transmitted has one bit added so number of ones is even (or odd)
Checked upon receipt – reject if number of ones is NOT even (odd)
>99% of all transmission errors are in one bit
Example Original: 0110 0011 Sent: 0110 0011 00111 0101 0111 0101 1
Error Checking - Accuracy
Send a set of multiple (8) bytes as a matrix. Set parity bit on rows & columns
Example
1111 1111 0000 0000 0010 0010 0110 1110
Error Correcting Parity
Send a set of multiple (8) bytes as a matrix. Set parity bit on rows & columns
Example – even parity
1111 1111 0 0000 0000 0 0010 0010 0 0110 1110 1 1011 0011
Error Correcting Parity
Send a set of multiple (8) bytes as a matrix. Set parity bit on rows & columns
Example – even parity – one bit error
1111 1111 0 0000 0100 0* 0010 0010 0 0110 1110 1 1011 0011 *
Error Correcting Parity
If m & n are integers, m ≠ 0, n can be written as n = m*q + r, where 0 <= r < |m|.q & r are the quotient & remainder of n/m
Examples:
Divide 82 by 7 ~~ 82 = 11 * 7 + 5
Divide 26 by 7 ~~ 26 = 3 * 7 + 5
* 82 & 26 are Congruent Modulo 7 because they have the same remainder
Division Algorithm
Define the congruence relation as follows:
Cm = {(a,b)| a & b are integers & have the same remainder when divided by m}
Example:
C7 = {(82,26), (5,12), (19,5) (4,11), (2,23) (49,0)…}
Congruence ~ is a Relation
Reflexive?Symmetric?Transitive?Notation: 82 ≡ 26 mod 7
49 ≡ 0 mod 7 Are there equivalence classes?
Properties of Congruence
Given Cm, how many equivalence classes?
Example: Consider C7
[0] = {[1] = {[2] = {Any more???
Equivalence Classes for Congruence
Given Cm, how many equivalence classes?
Example: C7
[0] = {0, 7, 14, 21,…} [4] =[1] = {1, 8, 15, 22,…} [5] = [2] = {2, 9, 16, 23,…} [6] =[3] = {3, 10, 17, 24…} [7] =
Equivalence Classes for Congruence
Clock Time Hours: (mod 12) + 1 mod 24
Clock Time Minutesmod 60
Examples of Congruence
Calendars ~ Days of the WeekIf Sunday = 0, Monday = 1, etc…..Mod 7 will give us days of week IF used correctly
Examples of Congruence
January 1, 2000 was a Saturday.
Add a separate function to your MODIFIED Calendar program to also print the day of the week for each of the days in the original data list using the mod function. Use the number of the day you calculated, NOT the strategy shown in example 3.7 in your text book. This project MUST be done individually, not as a team. A new data file with additional dates will be posted. All 3 columns must be aligned. Dates with single digits, MUST have the zeroes added. E.G. 05-04-2001
Program 2 – More CalendarDue: Thursday, October 9
If m & n are integers, m ≠ 0, n can be written as n = m*q + r, where 0 <= r < |m|. (Note r MUST be positive)
q & r are the quotient & remainder of n/m
Examples: -34/7 – Which is correct?? -34 = -4 * 7 – 6 r = -6 -34 = -5 * 7 + 1 r = 1
Note on Modulus on Negatives
Page 105 Problems 1 – 16, 37, 38
Homework – Section 3.1
Given 2 integers A & B, the largest integer that divides both is called the Greatest Common divisor (GCD)
Examples:GCD (12,8)GCD (200, 1000)GCD (7, 122)
Euclidean Algorithm*Greatest Common Divisor (GCD)
Let a, b, c, & q be integers with b > 0.
If a = qb + c, then gcd(a,b) = gcd(b,c)
Example: find gcd(105, 231)
gcd(231, 105) 231 = 2 * 105 + 21
gcd(105, 21) 105 = 5 * 21 + 0
gcd(21, 0) = 21
Theorem 3.3 (p.107)
r-1 = m, r0 = n, I = 0While rI≠0 //(division algorithm)
I = I + 1determine qI, rI for rI-2/rI-1
Print rI-1
The Euclidean Algorithm (p.108)Calculates gcd(m,n)
Lame – 1844: no more than 5 * number of digits in smaller of 2 numbers
Theorem 3.4 (p. 109)If the Euclidean Alg. is applied to m & n with m ≥ n > 0, the number of divisions needed is less than or equal to 2 log2 (n+1).
Thus, O(log2 n).
Complexity of Euclidean Algorithm
Page 111-112Problems 1 – 12
Page 149Problems 1 – 4, 15 - 18
Omitting Extended Euclidean Algorithm Sections 3.2 – 3.6
Homework – Section 3.2, Supplemental