Problem 104: Compressed Matching in the Fibonacci Word |
Compressed matching refers to the following problem: given compact representations of a pattern and of a text, locate the pattern in the text in a fast manner according to their compressed representations. The representation sizes can be logarithmic with respect to the real input sizes, as it takes place in this problem example.
The input depends on the type of compressed representation. Here we consider a very simple case where the pattern is specified as a concatenation of Fibonacci words and its representation is the sequence of their indices. The searched text is the infinite Fibonacci word $\mathbf{f}=\phi^{\infty}(\sa{a})$, where $\phi$ is the morphism defined by $\phi(\sa{a})=\sa{ab}$ and $\phi(\sa{b})=\sa{a}$.
The word $\sa{b}$ is added with index $-1$ to the list of Fibonacci words: $\fib_{-1}=\sa{b}$, $\fib_0=\sa{a}$, $\fib_1=\sa{ab}$, $\fib_2=\sa{aba}$, $\fib_3=\sa{abaab}$, \dots