Minimum length of character ring to contain all M-char strings on N-char set

7 Views Asked by At

With two characters a and b, there are 2^2 strings of length 2: aa, ab, ba, bb.

For any strings of length 4 on character set {a, b}, it cannot contain all the strings of length 2 (aa, ab, ba, bb), since for a string of length 4, it has totally 3 substrings of length 2, less than 2^2. But for a character ring of length 4, for example a ring of abba, it can contain all 2-char strings aa, ab, ba, bb.

Suppose the character set has cardinal N (i.e., N characters in total). What is the minimum length of a ring that contains all the strings of length M?