EXAMPLE 3 Encoding and Decoding a Message

Let’s revisit the message 1001 that we considered in Figure 17.1. Then, and

So, because , we have .

How is the intended message determined from a received encoded message? This process is called decoding. Say, for instance, that the message 1000, which has been encoded using parity-check sums as , is received as (an error in the third position). We simply compare with each of the 16 code words (that is, the possible correct messages) in Table 17.1 and decode it as the one that differs from in the fewest positions. (Put another way, we decode as the code word that agrees with in the most positions.) This method works even if the error in the message is one of the check digits rather than one of the digits of the original message string. When there is more than one code word that differs from in the fewest positions, we do not decode.