6
$\begingroup$

A set of words S is called self-segregating if you don't need whitespaces to read them. It means that for any two words from S no new words from S arise between them.

For example the set ab, bc, ac, ca is not self-segregating because ca is formed between bc and ab

Given an alphabet of N letters what is the maximum possible size of a self-segregating set of words of length n?

For two-lettered words, i.e. n=2, it's easy to prove that the answer is the floor of ${N^2}/{3}$.

But for n>2 the problem seems very difficult. I cannot solve it even for n=3.

$\endgroup$
7
  • 1
    $\begingroup$ Does it count if it takes three or more words to make another? (You refer only to two.) For example, if we have words ab, bc, cd, abbcc, then we can make the final word as a subword of the first three concatenated. But also, in your example, since all words have length two, any conjunction of those words is uniquely parsable, since we just take first two letters, next two, etc. In this sense, you don't need whitespace to read them. So I am confused about the precise definition of self-segregating. $\endgroup$ Commented Mar 4 at 16:43
  • $\begingroup$ It's about n-lettered words. And it's all about what is between 2 adjacent words. $\endgroup$ Commented Mar 4 at 16:46
  • 2
    $\begingroup$ Could you state more precisely what it means to be self-segregating? After all, I don't need whitespace to parse words uniquely when they all have the same number of letters, so what you've written doesn't seem to be what you mean. I guess you mean that if $s$ and $t$ are words in the set, then $st$ has no other connected subword from the set. $\endgroup$ Commented Mar 4 at 16:50
  • $\begingroup$ But what if we don't know where the beginning is? My first definition is informal, but the second one is correct. $\endgroup$ Commented Mar 4 at 16:51
  • $\begingroup$ I guess you mean that if s and t are words in the set, then st has no other connected subword from the set. Yes. This is what I meant. $\endgroup$ Commented Mar 4 at 16:54

1 Answer 1

6
$\begingroup$

Here is a solution for $n=3$.

1. We claim that maximum cardinality of $S$ is $(N-1)N(N+1)/3$. Notice that this is achieved by the set of all words of the form $a_ia_ja_k$ with $i\geq j<k$: this set is self-segregating, and the number of such words with middle letter $a_j$ is $j(j-1)$, so the total number of words is $$ \sum_{j=1}^N j(j-1)=\frac{(N-1)N(N+1)}3. $$

It remains to prove the upper bound.

2. Given a self-segregating set $S$, sonsider the following digraph $G$ with $N$ letters $a_1,a_2,\dots,a_N$ as vertices. We draw a red edge $a_i\to a_j$ if $S$ contains a word of the form $a_ia_j*$, and a blue such edge if $S$ contains a word of the form $*a_ia_j$. Denote by $B_0$ the set of vertices having zero blue in-degree, and by $R_0$ the set of vertices having zero red out-degree.

Say that an ordered pair $(a_i,a_j)$ is bad if there are both red and blue edges $a_i\to a_j$. This means that $S$ contains some words $U=xa_ix_j$ and $V=a_ia_jy$. In this case, there should be no word $W$ ending with $x$ (otherwise $U$ would appear between $W$ and $V$), and, similarly, no word starting with $y$; hence in this case $x\in B_0$ and $y\in R_0$ for any such $x$ and $y$.

So, given the graph $G$, all words $a_ia_ja_k$ that may appear in $S$ are determined as follows:

$\bullet$ there are a red edge $a_i\to a_j$ and a blue edge $a_j\to a_k$;

$\bullet$ moreover, if $(a_i,a_j)$ is bad, then $a_k\in R_0$; similarly, if $a_j\to a_k$ is bad, then $a_i\in B_0$.

Surely, we may (and will) assume that every edge in $G$ serves for at least one such word, otherwise we may remove the edge from the graph harmlessly.

Denote the set of such words by $W(G)$. It is now easily seen that, for any $G$, the set $W(G)$ is self-segregating. So we need to bound the maximum cardinality of $W(G)$ over all digraphs $G$.

3. Now we show by induction on $N$ that, for every digraph $F$ on $N$ vertices, we have $|S|\leq (N-1)N(N+1)/3$, where $S=W(G)$. The base case $N=1$ is trivial, as the only word $aaa$ cannot lie in $S$. Now we prerform the step.

Case A. Assume first that $B_0$ is non-empty. Consider any letter $b\in B_0$; we claim that it appears in at most $N(N-1)$ words in $S$, which allows to remove this letter and perform the inductive step.

As $b\in B_0$, the letter $b$ cannot appear at the end of a word in $S$. So any word in $S$ containing $b$ must contain a subword $ba$ with $a\neq b$. For any such $a$, we show that $ba$ appears in at most $N$ words from $S$, thus proving the desired bound. There are two subcases:

(i) If there is at most one edge $b\to a$, then $ba$ may appear in a fiixed position of a word in $S$, so there are indeed at most $N$ such words.

(ii) Otherwose, the pair $(b,a)$ is bad. So all words of the form $xba$ in $S$ have $x\in B_0$, while all words of the form $bay$ have $y\notin B_0$, as $a\to y$ is a blue edge. So $ba$ again appears in at most $N$ words from $S$. This finishes case A.

Case B. Now assume that $B_0$ is empty; in particular, there is no bad pair. In this case, we may assume that any ordered pair of vertices is connected by exactly one edge.

For any letter $a$, denote by $f(a)$ the sum of its red in-degree $r(a)$ and its blue out-degree $b(a)$. Then $a$ appears in $r(a)b(a)\leq \lfloor f(a)^2/4\rfloor$ words from $S$. So it suffices to show that $$ \sum_a \left\lfloor \frac{f(a)^2}4\right\rfloor\leq \frac{(N-1)N(N+1)}3. $$

Order the vertices as $a_1,a_2,\dots,a_N$ so that $f(a_1)\geq f(a_2)\geq\dots\geq f(a_N)$. Notice that for every $k=1,2,\dots,N$ we have $$ \sum_{i=1}^k f(a_i)\leq k^2+2k(N-k)=k(2N-k), $$ as there can be at most one edge between any ordered pair of vertices. This literally means that the tuple $(2N-1,2N-3,\dots,3,1)$ majorizes $(f(a_1),f(a_2),\dots,f(a_N))$.

Denote $$ g(x)=\left\lfloor\frac{x+1}2\right\rfloor\left(x-\left\lfloor\frac{x+1}2\right\rfloor\right). $$ It is readily checked that $g$ is continuous, piecewise-linear, (non-strictly) convex, and $g(k)=\lfloor k^2/4\rfloor$ for all non-negative integer $k$. Therefore, Karamata's inequality yields $$ \sum_{i=1}^N \left\lfloor \frac{f(a_i)^2}4\right\rfloor=\sum_{i=1}^Ng(f(a_i)) \leq \sum_{i=1}^N g(2N+1-2i)=\frac{(N-1)N(N+1)}3, $$ as desired.

NB. Surely, the estimates from part 3 are tight on the example showed in part 1.

$\endgroup$
5
  • $\begingroup$ I myself spent a lot of brain-time on this but without success. It's a strange feeling to face someone smarter than myself. $\endgroup$ Commented Jun 8 at 16:47
  • $\begingroup$ I guess you must be ru.m.wikipedia.org/wiki/Богданов,_Илья_Игоревич. Could you tell me how much brain-time it took you to find the idea i >= j < k? And how much time to prove the upper bound? With the help of computer i found that S(3,3) = 8. But nothing more. $\endgroup$ Commented Jun 8 at 16:48
  • $\begingroup$ How did you find the idea, and what are perspectives on N>3 ? Is it hard even for you, or you know the idea but are lazy to go all the way? $\endgroup$ Commented Jun 8 at 16:55
  • $\begingroup$ Я кстати предлагал эту задачу для N=2 в качестве олимпиадной Константину Кнопу. $\endgroup$ Commented Jun 8 at 18:44
  • $\begingroup$ Google translate says the comment above is "By the way, I proposed this problem for N=2 as an olympiad problem to Konstantin Knop." $\endgroup$ Commented Jun 11 at 6:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .