Combinatorics · Lesson 4
Counting Unbordered Words
The counting problem
Let be the set of unbordered words of length over a -letter alphabet, and write .
Every word is either bordered or unbordered, but not both, so:
The Nielsen recurrence
The key fact: if is split into two halves, then inserting a symbol into the middle preserves “unbordered” status in exactly the ways captured below.
Intuition for the odd case: an unbordered word of length stays unbordered when a symbol is inserted in the middle, and every length- unbordered word arises exactly this way.
The even case subtracts exactly the words that would gain a border by that middle insertion: those of the form where is an unbordered word of length .
Exploring the recurrence
Use the table below to see how and grow:
| n | u2(n) | b2(n) | 2n |
|---|---|---|---|
| 0 | 1 | 0 | 1 |
| 1 | 2 | 0 | 2 |
| 2 | 2 | 2 | 4 |
| 3 | 4 | 4 | 8 |
| 4 | 6 | 10 | 16 |
| 5 | 12 | 20 | 32 |
| 6 | 20 | 44 | 64 |
u2(6) + b2(6) = 64 — every length-6 word over a 2-letter alphabet is either bordered or unbordered.
For example, : the binary unbordered words of length 4 are 0001, 0011, 0111, 1000, 1100, 1110 — six of them.
A limiting frequency
It can be shown that converges as . For binary words the limit is about — roughly a quarter of all binary words are unbordered.
Practice
Compute the count
How many unbordered words of length 3 are there over a 2-letter alphabet?
How many unbordered words of length 6 are there over a 3-letter alphabet?
Practice this topic →Every quiz from this lesson, at four difficulties.
References
- Combinatorics on words — Wikipedia
- Substring — Wikipedia
- OEIS A003000: number of unbordered words over a two-letter alphabet
- Lothaire, Combinatorics on Words, Cambridge University Press, 1997