# Simplest error detecting/correcting codes for math newbies

Suppose you have been given the task of teaching some basic coding theory to folks who are interested in math but have not taken algebra, number theory, etc. If you want to introduce codes, you might start out with codes that are just based on overall parity - for example, you might start out assuming serial communication, and introduce a code in which $11$ and $00$ were codewords while $01$ and $10$ were not. You can obviously extend this example to any number of bits, but the idea remains the same - and this is a pretty terrible code.

In the spirit of introducing as little abstraction, group theory, etc as possible, what is or are the next logical code(s) to introduce?

-
When I teach this, before delving into the Maths I make sure students understand why redundancy is critical here. My favourite example is that if announce an event for "February 13, 2013", I wouldn't need to specify it's a Wednesday, because you can compute this yourself. But if I make a mistake, and say it is on February 14, 2013, you wouldn't know it's the wrong date, unless you have information from other sources. But if I announce the event for "Wednesday, February 14, 2013", then you can tell there is a mistake, just by looking at the announcement, without any extra knowledge. –  Andreas Caranti Feb 13 '13 at 7:06
Are you sure you want codes that don't even let you detect errors? Even the terrible code you mention can do that. –  Hurkyl Feb 13 '13 at 9:14
Erasure recovery using a suitable Tanner graph is easy to understand, but does require graphs and parity checks. Another possibility (a way of introducing people to RS-codes) is to use visual aids. The codewords consist of ordinates of points on a line (fixed abscissas). If there are four points, you can easily spot which one has moved away from the line. With only three points you can only detect that they are not collinear, but can't tell which point is to be blamed. Then start thinking what happens if you allow lines and parabolas... –  Jyrki Lahtonen Feb 13 '13 at 12:59
@Hurkyl, good point. Question edited. –  tacos_tacos_tacos Feb 13 '13 at 23:33

I second what @RobertIsrael writes.

I have a talk for high-school students based on the Seven Questions, One Lie game, which involves the $(7,4)$ Hamming code and the Fano plane, and it's always quite successful. It's a good way to teach about the codes without appealing too much to algebra. See this post of Peter Cameron for an account.

I have also some slides for it, but they are in Italian. These other slides deal with the Fano plane. They are also in Italian, but it's mostly geometry, there's little talking. They show how you can decode just by doing geometry, like, the line through two distinct points.

-
I will second this. The Hamming code of length 7 is useful for teaching also because it has a simple decoding algorithm. See this question and in particular Dilip Sarwate's comments to my answer. You do have to explain the concept of a parity check. –  Jyrki Lahtonen Feb 13 '13 at 12:52

Why not show them a perfect binary $(7,16,3)$-code based on the Fano plane? Not much theory required, just a picture like http://en.wikipedia.org/wiki/File:Fano_plane.svg

-
Sorry, that requires a bit more explanation. The picture is pretty, but I'm at a loss translating it into a code. –  vonbrand Feb 13 '13 at 14:27
@vonbrand,please see my answer for links to further details. –  Andreas Caranti Feb 13 '13 at 15:18
@AndreasCaranti, my point was that Robert's answer doesn't stand on its own as written. –  vonbrand Feb 13 '13 at 15:20

I think the binary Hamming $(7,4,3)$ code is far and away the next best step because it has this simple visualization using three circles that you can find at the Wiki article. It doesn't require any background besides being able to do binary arithmetic. (Incidentally, my advisor was fond of calling this the "Mickey Mouse code" both because the circles can be arranged to resemble the character and because it can be taught to elementary schoolers.)

This really helps to graphically drive home how the parity bits interweave the information from the information bits. It also helps students get a better feel for how erronious bits can be corrected and detected by the redundancy. The next best thing about the binary Hamming codes in general is that they have easy-to-understand and easy-to-use parity check matrices.

If you want to take a break from binary codes and explore codes under different moduli, you might consider going with some of the simple codes with parity check matrices $[1,1,\dots,1]$ or $[1,1,\dots, 1,-1]$. They are only very simple codes with a single parity check, but they are used in a lot of places (none of which I can remember instantly.)

It also makes it easy to segueway into codes with slightly more complicated but still 1-dimensional parity checks like $[1,3,1,3,\dots]$. I'm not a big fan of For all practical purposes but it does contain a lot of nice examples along these lines from everyday life, like UPC codes and ISBN codes.

-

The Hamming code is a good suggestion, but, going back to your question where you mentioned the code with words 00 and 11, I suggest you also mention the code with words 000 and 111, so that you can point out the difference between detecting a (single) error and correcting it. Then, when you continue with more respectable codes, you'll have a framework for saying how good they are.

-

Maybe the ISBN-Code, demonstrating that it can detect any single altered digit and any transposition of two adjacent digits. Note that only the older ISBN-10 has this property, but not the newer ISBN-13.

-