English

Small-Space Algorithms for the Online Language Distance Problem for Palindromes and Squares

Data Structures and Algorithms 2024-05-01 v2

Abstract

We study the online variant of the language distance problem for two classical formal languages, the language of palindromes and the language of squares, and for the two most fundamental distances, the Hamming distance and the edit (Levenshtein) distance. In this problem, defined for a fixed formal language LL, we are given a string TT of length nn, and the task is to compute the minimal distance to LL from every prefix of TT. We focus on the low-distance regime, where one must compute only the distances smaller than a given threshold kk. In this work, our contribution is twofold: - First, we show streaming algorithms, which access the input string TT only through a single left-to-right scan. Both for palindromes and squares, our algorithms use O(kpoly logn)O(k \cdot\mathrm{poly}~\log n) space and time per character in the Hamming-distance case and O(k2poly logn)O(k^2 \cdot\mathrm{poly}~\log n) space and time per character in the edit-distance case. These algorithms are randomised by necessity, and they err with probability inverse-polynomial in nn. - Second, we show deterministic read-only online algorithms, which are also provided with read-only random access to the already processed characters of TT. Both for palindromes and squares, our algorithms use O(kpoly logn)O(k \cdot\mathrm{poly}~\log n) space and time per character in the Hamming-distance case and O(k4poly logn)O(k^4 \cdot\mathrm{poly}~\log n) space and amortised time per character in the edit-distance case.

Keywords

Cite

@article{arxiv.2309.14788,
  title  = {Small-Space Algorithms for the Online Language Distance Problem for Palindromes and Squares},
  author = {Gabriel Bathie and Tomasz Kociumaka and Tatiana Starikovskaya},
  journal= {arXiv preprint arXiv:2309.14788},
  year   = {2024}
}

Comments

Accepted to ISAAC'23

R2 v1 2026-06-28T12:32:34.440Z