Problem 74: Computing Runs on General Alphabets |
The goal of the problem is to design an algorithm for computing runs in a word without any extra assumption on the alphabet. To say it differently, the algorithm should use the equality model on letters, that is, use only $=$/$\neq$ letter comparisons when necessary.
Problem 87 deals with computing runs on linear-sortable alphabets, a necessary condition to obtain a linear-time algorithm.
A run in a word $x$ is a maximal periodicity or a maximal occurrence of a periodic factor of $x$. Formally, it is an interval of positions $[i\dd j]$ for which the (smallest) period $p$ of $x[i\dd j]$ satisfies $2p\leq j-i+1$, and both $x[i-1]\neq x[i+p-1]$ and $x[j+1]\neq x[j-p+1]$ when the inequalities make sense. The centre of run $[i\dd j]$ is the position $i+p$.
To avoid reporting the same run twice, they can be filtered out according to their centre. To do so, we say that a run is right centred in the product $uv$ of words if it starts at a position on $u$ and has its centre on $v$. And we say it is left centred in $uv$ if its centre is on $u$ and it ends in $v$.