ArticleslgStudy

science

Constant-weight code

Constant-weight code is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Constant-weight code rather than just read about it. In short: In coding theory, a constant-weight code, also called an m-of-n code or m-out-of-n code, is an error detection and correction code where all codewords share the same Hamming weight. The one-hot code and the balanced code are two widely used kinds of constant-weight code.

Key takeaways

  • Constant-weight code belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Constant-weight code to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Constant-weight code from memory before moving on to harder problems.

Reference excerpt

In coding theory, a constant-weight code, also called an m-of-n code or m-out-of-n code, is an error detection and correction code where all codewords share the same Hamming weight. The one-hot code and the balanced code are two widely used kinds of constant-weight code. The theory is closely connected to that of designs (such as t-designs and Steiner systems). Most of the work on this field of discrete mathematics is concerned with binary constant-weight codes. Binary constant-weight codes have several applications, including frequency hopping in GSM networks. Most barcodes use a binary constant-weight code to simplify automatically setting the brightness threshold that distinguishes black and white stripes. Most line codes use either a constant-weight code, or a nearly-constant-weight paired disparity code. In addition to use as error correction codes, the large space between code words can also be used in the design of asynchronous circuits such as delay insensitive circuits. Constant-weight codes, like Berger codes, can detect all unidirectional errors.

A(n, d, w) The central problem regarding constant-weight codes is the following: what is the maximum number of codewords in a binary constant-weight code with length n, Hamming distance d, and weight w? This number is called A(n,d,w). Apart from some trivial observations, it is generally impossible to compute these numbers in a straightforward way. Upper bounds are given by several important theorems such as the first and second Johnson bounds, and better upper bounds can sometimes be found in other ways. Lower bounds are most often found by exhibiting specific codes, either with use of a variety of methods from discrete mathematics, or through heavy computer searching. A large table of such record-breaking codes was published in 1990, and an extension to longer codes (but only for those values of d and w which are relevant for the GSM application) was published in 2006.

1-of-N codes

A special case of constant weight codes are the one-of-N codes, that encode log2N bits in a code-word of N bits. The one-of-two code uses the code words 01 and 10 to encode the bits '0' and '1'. A one-of-four code can use the words 0001, 0010, 0100, 1000 in order to encode two bits 00, 01, 10, and 11. An example is dual rail encoding, and chain link used in delay insensitive circuits. For these codes, n=N, d=2, w=1 and A(n,d,w)=n. Some of the more notable uses of one-hot codes include biphase mark code uses a 1-of-2 code; pulse-position modulation uses a 1-of-n code; address decoder, etc.

Balanced code In coding theory, a balanced code is a binary forward error correction code for which each codeword contains an equal number of zero and one bits. Balanced codes have been introduced by Donald Knuth; they are a subset of so-called unordered codes, which are codes having the property that the positions of ones in a codeword are never a subset of the positions of the ones in another codeword. Like all unordered codes, balanced codes are suitable for the detection of all unidirectional errors in an encoded message. Balanced codes allow for particularly efficient decoding, which can be carried out in parallel. Some of the more notable uses of balanced-weight codes include biphase mark code uses a 1 of 2 code; 6b/8b encoding uses a 4 of 8 code; the Hadamard code is a 2k−1 of 2k code (except for the zero codeword), the three-of-six code; etc. The 3-wire lane encoding used in MIPI C-PHY can be considered a generalization of constant-weight code to ternary -- each wire transmits a ternary signal, and at any one instant one of the 3 wires is transmitting a low, one is transmitting a middle, and one is transmitting a high signal.

m-of-n codes An m-of-n code is a separable error detection code with a code word length of n bits, where each code word contains exactly m instances of a "one". A single bit error will cause the code word to have either m + 1 or m − 1 "ones". An example m-of-n code is the 2-of-5 code used by the United States Postal Service. The simplest implementation is to append a string of ones to the original data until it contains m ones, then append zeros to create a code of length n. Example:

Some of the more notable uses of constant-weight codes, other than the one-hot and balanced-weight codes already mentioned above, include Code 39 uses a 3-of-9 code; bi-quinary coded decimal code uses a 2-of-7 code, the 2-of-5 code, etc.

References

External links Table of lower bounds on A(n,d,w) maintained by Andries Brouwer Table of upper bounds on A(n,d,w) maintained by Erik Agrell

Worked examples

Example 1 — a first encounter with Constant-weight code

Start with the simplest possible case. Write down what Constant-weight code claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Constant-weight code before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Constant-weight code ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Constant-weight code

In research
Constant-weight code appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Constant-weight code in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Constant-weight code is common in secondary-school and first-year university syllabi. It links to neighbouring topics Error detection and correction, Information theory, so understanding it makes those chapters shorter.
In everyday life
Look for Constant-weight code outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Constant-weight code” →

How to study Constant-weight code in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Constant-weight code means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Constant-weight code out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Constant-weight code in simple terms?

In coding theory, a constant-weight code, also called an m-of-n code or m-out-of-n code, is an error detection and correction code where all codewords share the same Hamming weight. The one-hot code and the balanced code are two widely used kinds of constant-weight code.

Why does Constant-weight code matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Constant-weight code?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Constant-weight code.

Tags

  • Error detection and correction
  • Information theory

Keep exploring