$\gib_2=\sa{a}$, $\gib_3=\sa{aba}$, $\gib_4=\sa{abaaba}$, $\gib_5=\sa{abaababaaba}$ and $\suf(3,5) = \sa{ababaaba}$.
$\suf(3,5) = \sa{ababaaba} = R_0\cdot R_1\cdot R_3 = \sa{a}\cdot\sa{ba}\cdot\sa{baaba}$ and $\mathcal{R}_5(3) = (0,1,3)$.
Problem 56: Comparing Suffixes of a Fibonacci Word |
The structure of Fibonacci words, like that of Thue-Morse words, is an example of a situation in which some algorithms can be optimised to run in logarithmic time with respect to the length of words. The problem is concerned with a fast lexicographic comparison between two suffixes of a finite Fibonacci word, which shows such a phenomenon.
We deal with a slightly shortened version of Fibonacci words to simplify arguments. Let $\gib_n$ be the $n$th Fibonacci word $\fib_n$ with the last two letters deleted, that is, $\gib_n = \fib_n\{\sa{a},\sa{b}\}^{-2}$, for $n \geq 2$. Let also $\suf(k,n)$ be the $k$th suffix $\gib_n[k\dd |\gib_n|-1]$ of $\gib_n$.
The comparison between suffixes of $\gib_n$ is efficiently reduced to the comparison of their compact representation of logarithmic length implied by their logarithmic-size decomposition (property below). Factors of the decomposition are the reverse $R_n=\fib_n^\mathrm{R}$ of Fibonacci words. The first factors are $R_0=\sa{a}$, $R_1=\sa{ba}$, $R_2=\sa{aba}$ and $R_3=\sa{baaba}$. Observe that $R_{n+2}=R_{n+1}R_n$ and $R_n$ starts with the letter $\sa{a}$ if and only if $n$ is even.
Related to the factorisation let $\mathcal{R}_n(k) = (i_0,i_1,\dots,i_m)$.