3.7. Parity Error Checking (optional)

Time Estimate: 45 minutes

3.7.1. Introduction and Goals

As you learned in the previous lesson, the card "trick" is really not a magic trick at all. It is a very precise algorithm of error checking based on the concept of parity.

In mathematics, parity refers to the evenness or oddness of a number. In the card trick, a parity bit was added to each row and column such that the additional bit would make the row or column have an even number of 1 bits. This is known as even parity. The "trick" would also work if the parity bits were set so as to make each row and column have an odd number of 1 bits. That would be known as odd parity.

It's important to realize that the parity bit is not part of the data. It is redundant, an extra bit, added to the data to allow us to detect if one of the data bits has been flipped from its original value.

Learning Objectives: I will learn to
  • identify binary sequences with odd and even parity
  • detect errors in bit sequences that contain parity bits
Language Objectives: I will be able to
  • use target vocabulary, such as even parity, odd parity, and parity bit while describing bit sequences and identifying errors, with the support of concept definitions and vocabulary notes from this lesson

3.7.2. Learning Activities

Parity Bit Error Detection

Suppose you are sending a stream of data to a server. By adding a parity bit, you enable the server to detect some basic transmission errors. For example, if the server expects that every byte will contain an even number of 1s and it detects a byte such as 00010101 with an odd number of 1s, it can tell that an error occured. Perhaps the user meant to send 0000 0101 but one of the bits was flipped from 0 to 1 during transmission.

A parity bit is a bit that is added as the leftmost bit of a bit string to ensure that the number of bits that are 1 in the bit string are even or odd.

To see how this works, suppose our data are stored in strings containing 7 bits. (You might remember that the ASCII scheme, when it was initially introduced, was a 7-bit code. In practice, a parity bit would be added to the ASCII code so that 1-bit errors could be detected in the resulting 8-bit byte.)

In an even parity scheme the eighth bit, the parity bit, is set to 1 if the number of 1s in the 7 data bits is odd, thereby making the number of 1s in the 8-bit byte an even number. It is set to 0 if the number of 1s in the data is even.

In an odd parity scheme the eighth bit, the parity bit, is set to 1 if the number of 1s in the 7 data bits is even, thereby making the number of 1s in the 8-bit byte an odd number. It is set to 0 if the number of 1s in the data is odd.

The following table summarize this approach.

Data Bits (7)Add a parity bit to get 8 bits
Even Parity
Total number 1s is even
Odd Parity
Total number of 1s is odd
000 0000 (0 1s)0000 00001000 0000
011 0010 (3 1s)1011 00100011 0010
011 0011 (4 1s)0011 00111011 0011
011 0111 (5 1s)1011 01110011 0111

Parity Exercise

3.7.3. Summary

In this lesson, you learned how to:

3.7.4. Still Curious?

As you learned in this lesson, with 1 redundant parity bit you can detect 1-bit errors in a stream of bits. Actually, you could detect that an error occurred if 1, 3, 5, or any odd number of bits were flipped, but not 2, 4, 6. or any even number of bits.

Detecting an error in a bit stream means that the bit stream would have to be retransmitted. Or, if writing the bit stream to the disk, it would have to be rewritten.

Error Correction Codes

Is it possible to correct errors as well as detect them? The answer is 'yes' but it will require more, redundant bits. Actually, you saw this with the card trick. In that case, each data bit had two parity bits, one at the end of its row and one at the end of its column. That's what enabled us to identify the exact bit that was flipped (in the case of a single bit). And the intersection of the row and column that had the wrong parity, is how we identified the bit. If you can identify the bit that was flipped, then you can correct it by flipping it back.

A more general way of correcting errors such as this is known as Hamming Code and the following video shows how this very interesting approach works.



3.7.5. Self-Check

Vocabulary

Here is a table of the technical terms we've introduced in this lesson. Hover over the terms to review the definitions.

parity
even parity
odd parity
parity bit

Check Your Understanding

Complete the following self-check exercises.

3.7.6. Reflection: For Your Portfolio

Answer the following portfolio reflection questions as directed by your instructor. Questions are also available in this Google Doc where you may use File/Make a Copy to make your own editable copy.

You have attempted of activities on this page