# 3.6. Error Detection¶

This lesson, which is adapted from Computer Science Unplugged, uses a card trick to illustrate how extra bits in a binary sequence can be used to detect certain kinds of errors. It reinforces the enduring understanding that a variety of abstractions built upon binary sequences can be used to represent all digital data.

### Professional Development

The Student Lesson: Complete the activities for Mobile CSP Unit 3 Lesson 3.6: Error Detection.

### Materials

• Playing cards or 0/1 cards are useful for this lesson. Here are some options:
• Set of cards to use on the board (magnetic, large post-it notes or similar that are sticky on both sides)
• Set of cards for groups of 3 students (card stock that has a different color on each side)
• Alternatives (in-person): pennies (heads/tails would be 0/1), 0/1 bit cards, deck of playing cards
• Alternatives (online teaching): Slide where students can move cards into place, Virtual playing cards, the android widget built into lesson.
• POGIL handout

## 3.6.1. Learning Activities¶

### Estimated Length: 45 minutes

• Hook/Motivation (5 minutes): Ask the students: Now that you know that all data in a computer are stored in bits, in sequences of binary 0s and 1s, what might an error look like when you store or transmit some data? When data is corrupted it is said to contain an error.
"When data is stored on a disk or transmitted from one computer to another, we usually assume that it doesn’t get changed in the process. But, sometimes things go wrong and the data is changed accidentally. This activity uses a magic trick to show how to detect when data has been corrupted, and to correct it." -CS Unplugged
• Experiences and Explorations (30 minutes):
• Card Trick Demo (5 minutes): Do the error detection card trick with students using a deck of cards or the online widget or virtual playing cards. The CS Unplugged error detection card trick page contains videos of the trick being done. The CS Unplugged error detection card trick pdf explains how the trick is done:
• Have a pile of cards ready. The cards could all be black on one side and white on the other, or you could use a deck of playing cards with the face as the white side and the back as the black side, or some printed 0/1 bit cards
• Ask for a student volunteer to layout a 5 x 5 grid of cards. The cards can be in any order.
• When the student has finished laying out the grid, then casually lay out the additional row and column (the parity bits). When adding a card to each row and column, make sure the number of black cards in that row or column is always even. For example, if the row the student volunteer has made has 1 black cards and 4 white cards, then you add a black card to that row to make the total number of blacks in that row 2, an even number. Simply tell the students you are adding these cards to make the trick 'harder." Do not explain how/why you are really adding the extra cards.
• Ask for another student volunteer to switch out any card and replace it with the opposite color card while you leave the room or look away.
• Come back and do the trick - "magically" spot which card was flipped while you were looking by finding which row and column has an odd number of black cards.
• Ask the students if they have any insight on what you may have done.
• POGIL Activity (25 minutes): Break students into teams of 3-4 and have them complete the critical thinking questions. Make sure students are following their roles and that each student in the group understands the card trick.
• Rethink, Reflect and/or Revise (10 minutes): Ask the students to write a reflection in their Google portfolio that describes the error detection card trick, how it is performed, and what they learned about error detection. If time permits, have the students try some interactive exercises.

### AP Classroom

The College Board's AP Classroom provides a question bank and Topic Questions. You may create a formative assessment quiz in AP Classroom, assign the quiz (a set of questions), and then review the results in class to identify and address any student misunderstandings.The following are suggested topic questions that you could assign once students have completed this lesson.

Suggested Topic Questions:

None

### Assessment Opportunities

Solutions:

Assessment Opportunities

You can examine students’ work on the interactive exercise and their reflection portfolio entries to assess their progress on the following learning objectives. If students are able to do what is listed there, they are ready to move on to the next lesson.

• Interactive Exercises:
• Portfolio Reflections:
LO X.X.X - Students should be able to ...
• In the XXX App, look for:

### Differentiation: More Practice

If students are having trouble understanding the card trick, have them watch the CS Unplugged video that shows the solution.

### Differentiation: Enrichment

Have students explore the conditions under which two cards being flipped does work and when it does not work.

### Background Knowledge: Error Detection Card Trick

MATHmaniaCS provides a very detailed explanation on how you can do the magic trick with your students.

For the 5 × 5 table, if you count the number of 1s you get the following results:

```Row   #of 1s         Column     #1s
1       1                 1      2
2       2                 2      2
3       1                 3      1
4       1                 4      0
5       1                 5      1
```

For the 6 × 6 table, if you count the number of 1s you get the following results:

```Row   #of 1s         Column     #1s
1       2                 1      2
2       2                 2      2
3       2                 3      2
4       2                 4      0
5       2                 5      2
6       2                 6      4
```

The difference in the 6 × 6 case is that all of the rows and columns have an even number of 1s. If you "flip" a 1 to a 0 or a 0 to a 1 in the 6 × 6 table, you will destroy this pattern, making 1 row and 1 column have an odd number of 1s. The intersection of that row and column will indicate the bit that was flipped. For example, count the 0s and 1s in rows and columns of this 6 × 6 table and you'll see that the rows and columns with an odd number of bits intersect at the flipped (red) bit.

The 6 by 6 table with a flipped bit. The blue numbers give the number of 1s in each row and column.

 1 0 0 0 0 1 2 0 1 0 0 1 0 2 0 0 0 0 0 1 1 1 0 0 0 0 1 2 0 1 0 0 0 1 2 0 0 1 0 1 0 2 2 2 1 0 2 4

### Teaching Tips: Practice, Practice, Practice

Practice the card trick with friends or family so that you feel comfortable performing it in front of the students. If not, show the demo video instead until you have it down. You can order your own Notable Women in Computing deck of cards—the same ones used in the video demo.

## 3.6.2. Professional Development Reflection¶

Discuss the following questions with other teachers in your professional development program.

• How does this lesson help students toward the enduring understanding that the way a computer represents data internally is different from the way the data is interpreted and displayed for the user?
[EU DAT-1]

I am confident I can teach this lesson to my students.
• 1. Strongly Agree
• 2. Agree
• 3. Neutral
• 4. Disagree
• 5. Strongly Disagree