Skip to main content
QUICK REVIEW

[Paper Review] Small-Space Algorithms for the Online Language Distance Problem for Palindromes and Squares

Gabriel Bathie, Tomasz Kociumaka|arXiv (Cornell University)|Jan 1, 2023
semigroups and automata theoryComputer Science1 citations
TL;DR

This paper presents space-efficient streaming and read-only online algorithms for computing the minimal Hamming and edit distances from every prefix of an input string to the languages of palindromes and squares, under a low-distance regime (threshold k). It introduces randomized streaming algorithms using O(k polylog n) space and time per character, and deterministic read-only algorithms with O(k polylog n) space for Hamming distance and O(k⁴ polylog n) space for edit distance, achieving poly(k, log n) complexity for both models.

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 $L$, we are given a string $T$ of length $n$, and the task is to compute the minimal distance to $L$ from every prefix of $T$. We focus on the low-distance regime, where one must compute only the distances smaller than a given threshold $k$. In this work, our contribution is twofold: - First, we show streaming algorithms, which access the input string $T$ only through a single left-to-right scan. Both for palindromes and squares, our algorithms use $O(k \cdot\mathrm{poly}~\log n)$ space and time per character in the Hamming-distance case and $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 $n$. - Second, we show deterministic read-only online algorithms, which are also provided with read-only random access to the already processed characters of $T$. Both for palindromes and squares, our algorithms use $O(k \cdot\mathrm{poly}~\log n)$ space and time per character in the Hamming-distance case and $O(k^4 \cdot\mathrm{poly}~\log n)$ space and amortised time per character in the edit-distance case.

Motivation & Objective

  • To address the online language distance problem for the formal languages of palindromes and squares under low-distance constraints.
  • To design space-efficient algorithms that process input strings in a single left-to-right scan (streaming) or with read-only random access to past characters.
  • To achieve poly(k, log n) time and space complexity for both Hamming and edit distance variants, with a focus on the threshold k regime.
  • To develop the first poly(k, log n) space read-only algorithms for k-mismatch and k-edit pattern occurrences in text.

Proposed method

  • Leverages randomized streaming techniques with sketching for Hamming distance, using tools from approximate pattern matching.
  • Applies locally consistent string decompositions and edit distance sketches to reduce edit distance computation to Hamming distance problems.
  • Employs k-mismatch and k-error pattern matching with mismatch information (MI) tracking to detect potential palindromic or square substrings.
  • Uses structural properties of palindromes and squares—such as self-similarity and periodicity—to guide efficient detection and distance computation.
  • Processes each character in O(k polylog n) time by maintaining O(k) mismatch information sets and applying triangle inequality bounds.
  • For the read-only model, maintains persistent data structures with O(k) space per level, using hierarchical pattern matching across multiple levels of string decomposition.

Experimental results

Research questions

  • RQ1Can we design randomized streaming algorithms for online language distance to palindromes and squares with poly(k, log n) space and time per character for both Hamming and edit distances?
  • RQ2What is the minimal space and time complexity achievable for deterministic online algorithms with read-only access to past input characters?
  • RQ3How can we efficiently detect k-mismatch or k-error occurrences of patterns that may form palindromes or squares in real-time?
  • RQ4Can structural properties of palindromes and squares be exploited to reduce the complexity of distance computation in the low-distance regime?
  • RQ5What are the trade-offs between randomized streaming and deterministic read-only models in terms of space, time, and correctness guarantees?

Key findings

  • Randomized streaming algorithms achieve O(k polylog n) space and time per character for Hamming distance and O(k² polylog n) for edit distance, with inverse-polynomial error probability.
  • Deterministic read-only algorithms use O(k polylog n) space and time per character for Hamming distance, and O(k⁴ polylog n) space and amortized time per character for edit distance.
  • The first poly(k, log n) space read-only algorithms for k-mismatch and k-edit pattern occurrences in text are developed as a byproduct.
  • For k-LHD-PAL and k-LHD-SQ, the streaming algorithm uses ˜O(k) time and O(k log n) space, improving upon prior ˜O(k²) time bounds.
  • The read-only algorithm for k-LHD-PAL/SQ runs in O(k log n) time and space per character, matching the best known bounds for similar problems.
  • For edit distance, the read-only algorithm achieves ˜O(k⁴) time and space per character, with amortized efficiency, marking a significant step for deterministic online computation.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.