chapter 17: binary codes
DESCRIPTION
Math for Liberal Studies. Chapter 17: Binary Codes. What is a binary code?. A binary code is a system for encoding data made up of 0’s and 1’s Examples Postnet (tall = 1, short = 0) UPC (dark = 1, light = 0) Morse code (dash = 1, dot = 0) Braille (raised bump = 1, flat surface = 0) - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/1.jpg)
Math for Liberal Studies
![Page 2: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/2.jpg)
A binary code is a system for encoding data made up of 0’s and 1’s
Examples Postnet (tall = 1, short = 0) UPC (dark = 1, light = 0) Morse code (dash = 1, dot = 0) Braille (raised bump = 1, flat surface = 0) Movie ratings (thumbs up = 1, thumbs down = 0)
![Page 3: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/3.jpg)
CD, MP3, and DVD players, digital TV, cell phones, the Internet, space probes, etc. all represent data as strings of 0’s and 1’s rather than digits 0-9 and letters A-Z
Mostly, whenever information needs to be transmitted from one location to another, a binary code is used
![Page 4: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/4.jpg)
What are some problems that can occur when data is transmitted from one place to another?
The two main problems are transmission errors: the message sent is not the
same as the message received security: someone other than the intended
recipient receives the message
![Page 5: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/5.jpg)
Suppose you were looking at a newspaper ad for a job, and you see the sentence “must have bive years experience”
We detect the error since we know that “bive” is not a word
Can we correct the error? Why is “five” a more likely correction than
“three”?
![Page 6: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/6.jpg)
Suppose NASA is directing one of the Mars rovers by telling it which crater to investigate
There are 16 possible signals that NASA could send, and each signal represents a different command
NASA uses a 4-digit binary code to represent this information
0000 0100 1000 11000001 0101 1001 11010010 0110 1010 11100011 0111 1011 1111
![Page 7: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/7.jpg)
The problem with this method is that if there is a single digit error, there is no way that the rover could detect or correct the error
If the message sent was “0100” but the rover receives “1100”, the rover will never know a mistake has occurred
This kind of error – called “noise” – occurs all the time
![Page 8: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/8.jpg)
One way to try to avoid these errors is to send the same message twice
This would allow the rover to detect the error, but not correct it (since it has no way of knowing if the error occurs in the first copy of the message or the second)
There is a better way to allow the rover to detect and correct these errors, and only requires 3 additional digits
![Page 9: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/9.jpg)
The original message is four digits long We will call these digits I, II, III, and IV We will add three new digits, V, VI, and VII Draw three intersecting circles as shown here Digits V, VI, and VII should be
chosen so that each circlecontains an even number ofones
IIIIVII
I
VII
V VI
![Page 10: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/10.jpg)
The message we want to send is “0100” Digit V should be 1 so that the first circle has
two ones Digit VI should be 0 so that the second circle
has zero ones (zero is even!) Digit VII should be 1 so that
the last circle has two ones Our message is now 0100101
001
0
1
1 0
![Page 11: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/11.jpg)
Now watch what happens when there is a single digit error
We transmit the message 0100101 and the rover receives 0101101
The rover can tell that the second and third circles have odd numbers of ones, but the first circle is correct
So the error must be in the digit that is in the second and third circles, but not the first: that’s digit IV
Since we know digit IV is wrong, there isonly one way to fix it: change it from 1 to 0
011
0
1
1 0
![Page 12: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/12.jpg)
Encode the message 1110 using this method
You have received the message 0011101. Find and correct the error in this message.
![Page 13: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/13.jpg)
Binary codes can be used to represent more conventional information, but 4 digits only gives us 16 possible messages
That’s not even enough to represent the alphabet!
If we have n digits, then we can make 2n different messages
5 digits -> 32 messages 6 digits -> 64 messages, etc.
![Page 14: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/14.jpg)
The idea we’re using is a specific example of a parity check sum
The parity of a number is either odd or even For example, digit V is 0 if I + II + III is even,
and odd if I + II + III is odd
![Page 15: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/15.jpg)
Instead of using Roman numerals, we’ll use a1
to represent the first digit of the message, a2 to represent the second digit, and so on
We’ll use c1 to represent the first check digit, c2 to represent the second, etc.
![Page 16: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/16.jpg)
Using this notation, our rules for our check digits become c1 = 0 if a1 + a2 + a3 is even c1 = 1 if a1 + a2 + a3 is odd c2 = 0 if a1 + a3 + a4 is even c2 = 1 if a1 + a3 + a4 is odd c3 = 0 if a2 + a3 + a4 is even c3 = 1 if a2 + a3 + a4 is odd
![Page 17: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/17.jpg)
Under this new way of thinking about our system, how do we decode messages?
Simply compare the message with the list of possible correct messages and pick the “closest” one
What should “closest” mean? If you have two messages of the same length,
the distance between the two messages is the number of digits in which they differ
![Page 18: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/18.jpg)
What is the distance between 1100101 and 1010101? The messages differ in the 2nd and 3rd digits, so the
distance is 2
What is the distance between 1110010 and 0001100? The messages differ in all but the 7th digit, so the
distance is 6
![Page 19: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/19.jpg)
The nearest neighbor decoding method decodes a received message as the code word that agrees with the message in the most positions
![Page 20: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/20.jpg)
In this example, our messages are three digits long: a1a2a3
We have three check digits c1 = 0 if a1 + a2 + a3 is even c1 = 1 if a1 + a2 + a3 is odd c2 = 0 if a1 + a3 is even c2 = 1 if a1 + a3 is odd c3 = 0 if a2 + a3 is even c3 = 1 if a2 + a3 is odd
![Page 21: Chapter 17: Binary Codes](https://reader036.vdocuments.net/reader036/viewer/2022081501/5681519d550346895dbfcefb/html5/thumbnails/21.jpg)
Using these rules, we can find all of our code words
By analyzing this list,we see that the smallestdistance between twocode words is 3
That means we can usethese code words to either detect two errorsor correct one error
Message Code Word
000 000000
001 001111
010 010101
011 011010
100 100110
101 101001
110 110011
111 111100