For example consider , the language formed by the words that have exactly two symbols over a binary alphabet. A universal word for is 00011011.
It is clear that universal words always exist for any language. Now, we are interested in minimal length universal words. A minimal length universal word for the language above is 11001.
Let's have a look at a friendly family of languages for which there are minimal universal words with known length: the languages made of all the possible fixed -size words over an alphabet of symbols. You can prove that for such languages:
- any universal word of size is minimal,
- there exists a minimal length universal word of size ,
- constructing a minimal length universal word with any prefix of length can be done in time.
Here's such a word for :
00000000111111110111111001111101011111000111101101111010011110010111100001110111011001110101011101000111001101110010011100010111000001101101011011000110101001101001011010000110011001010110010001100010011000010110000001010101000101001001010000010010000100010000000I'm joining a simple and not too efficient python program for generating these, which basically is a constructive proof of existence. The obvious application of these are in bruteforcing digital locks that match the password with the last keys pressed every time a key is pressed. You only have to press an average of keys instead of , and this is optimal.
EDIT: Thanks Antony for pointing to the fact that these are called de Bruijn sequences.