Chapters 16 & 17 Sarah Cameron 18 March 2010 Review of Modular Arithmetic Identification Numbers • ZIP Codes • Bar Codes Binary Codes Encryption a mod n = the remainder when a is divided by n Examples: • 3 mod 2 = 1 • 37 mod 10 = 7 Identification Numbers: • Unambiguously identify the person or thing with which it is associated • Should be “self-checking” Five Digits: ABCDE A: Represents one of 10 geographic areas in the US, normally a grouping of states BC: These two digits in combination with the first, identify a central mail-distribution point known as a sectional center. DE: The last two digits indicate the town or local post office, the order is often alphabetical for towns within a delivery area 4 code: FGHJ FG: Represent a delivery sector. HJ: Narrow the area further based on the needs of the delivery sector. Bonus Trivia: Using the ZIP + 4 code makes you eligible for cheaper bulk rates. Binary Code: any system for representing data with only two symbols Bar Code: a series of dark and light spaces that represent characters Has been used since 1973. 12 Digit number: KLMNOPQRSTUV K: This digit identifies the kind of product. LMNOP: These digits identify the manufacturer. QRSTU: These digits are assigned by the manufacturer to identify the product. V: The final digit is the check digit. Check Digits • Used for error detection and correction • Can be the last digit in an ID number or a binary code. • Often for ID numbers: Sum the individuals digits and mod by the check digit Take binary string a1a2a3a4 and append three check digits c1c2c3 so that any single error in any of the seven positions can be corrected Choose 3 different sums: • c1 :a1 + a2 + a3 • c2 :a1 + a3 + a4 • c3 :a2 + a3 + a4 If the value of the check is even, the check digit should be zero. If the value of the check sum is odd, the check digit should be one. Using this method you are able to produce a list of all possible a1a2a3a4c1c2c3 combinations. Nearest-Neighbor Decoding • This method decodes a received message as the code word that agrees with the message in the most positions Distance Between Two Strings (of equal length) • The number of positions in which the strings differ. Example: • Real Message: 1000110 • Received as: 1010110 • The distance between the real message and the received message is one. If there are two possible translations for an erroneous message, it is not decoded. Binary Linear Code • Consists of words composed of 0’s and 1’s obtained from all possible messages of a given length by using parity-check sums to append check digits to the messages. These words are called code words. Weight of a Binary Code • Is the minimum number of 1’s that occur among all nonzero words of that code. Accuracy: • If the weight of a binary code is odd, the code will correct any (t-1)/2 or fewer errors. • If the weight of a binary code is even, the code will correct any (t-2)/2 or fewer errors. • If you simply want to detect errors, the code will detect t-1 errors Encryption • The process of disguising data Cryptology • The study of methods to make and break secret codes Data Compression • The process of encoding data so that the most frequently occurring data are represented by the fewest symbols VW U XZ Y B A C T D S E R P Q F O H N M L K J I G 1. Delete all occurrences of h and w. 2. Assign numbers to the remaining letters as follows: • • • • • • • 3. 0: A, E, I, O, U 1: B, F, P, V 2: C, G, J, K, Q, S, X, Z 3: D, T 4: L 5: M, N 6: R If two or more letters with the same numeric value are adjacent, omit all but the first. 4. Delete the first character of the original name, if still present. 5. Delete all occurrences of A, E, I, O, U, and Y. 6. Retain only the first three digits corresponding to the remaining letters. 7. Append trailing 0’s if fewer than three letters remain. 8. Precede the digits with the first letter of the name. A B C D E F G H I J K L MN O P Q R S T U V WX Y Z D E F G H I J K L M N O P Q R S T U V WX Y Z A B C • Used by Julius Caesar to send messages to his troops. • Decode “DWWDFN DW GDZQ” • The encoded message: “ATTACK AT DAWN” ATTACK AT DAWN 0 19 19 0 2 10 0 19 3 0 22 13 MATHMA TH MATH 12 0 19 7 12 0 19 7 12 0 19 7 MTMHOK ?? ???? 12 19 12 7 14 10 • Choose a key word, which can be anything. • Add the digit position of the original letter to the digit position of the key word letter. • Mod that number by 26 = digit position of the coded letter. • Repeat the key word for as many characters as you need. • Answer: TA PAPU;19, 0, 15, 0, 15, 20 Questions? Applications? Homework: (7th • Chapter 16: #74 • Chapter 17: #11 Edition)