Skip to main content
QUICK REVIEW

[Paper Review] Almost Linear Time Computation of Maximal Repetitions in Run Length Encoded Strings

Keita Kuboi, Yuta Fujishige|arXiv (Cornell University)|Jan 1, 2017
Algorithms and Data CompressionComputer Science9 references3 citations
TL;DR

This paper presents an O(mN + nM)-time algorithm for computing the longest common subsequence (LCS) of two strings A and B that must include a given constraint string C as a substring (STR-IC-LCS), where m and n are the sizes of the run-length encoded (RLE) forms of A and B. By exploiting RLE to reduce redundant computations and using a compact dynamic programming table with optimized interval combinations, the method achieves faster performance than the standard O(MN) approach, especially on compressible strings.

ABSTRACT

The constrained LCS problem asks one to find a longest common subsequence of two input strings $A$ and $B$ with some constraints. The STR-IC-LCS problem is a variant of the constrained LCS problem, where the solution must include a given constraint string $C$ as a substring. Given two strings $A$ and $B$ of respective lengths $M$ and $N$, and a constraint string $C$ of length at most $\min\{M, N\}$, the best known algorithm for the STR-IC-LCS problem, proposed by Deorowicz~({\em Inf. Process. Lett.}, 11:423--426, 2012), runs in $O(MN)$ time. In this work, we present an $O(mN + nM)$-time solution to the STR-IC-LCS problem, where $m$ and $n$ denote the sizes of the run-length encodings of $A$ and $B$, respectively. Since $m \leq M$ and $n \leq N$ always hold, our algorithm is always as fast as Deorowicz's algorithm, and is faster when input strings are compressible via RLE.

Motivation & Objective

  • To develop a faster algorithm for the STR-IC-LCS problem, which requires the LCS to include a given constraint string C as a substring.
  • To leverage run-length encoding (RLE) to compress input strings and reduce computational complexity.
  • To improve upon the best-known O(MN) time algorithm by Deorowicz (2012) for STR-IC-LCS.
  • To demonstrate that RLE-based methods are practically viable beyond artificial cases, especially in domains like music and time-series data.

Proposed method

  • The algorithm uses run-length encoding (RLE) to represent input strings A, B, and C, reducing their effective sizes to m, n, and |RLE(C)|, respectively.
  • It introduces a compact dynamic programming table (cDP table) that stores LCS lengths for prefixes and suffixes of RLE segments.
  • The method identifies minimal C-intervals in A and B—segments that contain C as a substring—and groups them into equivalence classes based on run types.
  • By exploiting Lemma 13, it reduces the number of interval combinations to consider from O(gg') to O(mN + nM), where g and g' are the number of minimal C-intervals.
  • It computes the LCS length for each relevant pair of minimal C-intervals using the cDP table in O(1) time per pair via Lemma 9.
  • The algorithm retrieves the actual STR-IC-LCS in O(m + n) time by backtracking through the cDP table and merging RLE segments.

Experimental results

Research questions

  • RQ1Can the STR-IC-LCS problem be solved faster than O(MN) time using run-length encoding?
  • RQ2How can the structure of RLE-compressed strings be exploited to reduce redundant LCS computations?
  • RQ3Is it possible to design a dynamic programming approach that scales with the RLE size m and n rather than the original string lengths M and N?
  • RQ4What is the theoretical and practical performance gain of using RLE in constrained LCS problems like STR-IC-LCS?

Key findings

  • The proposed algorithm computes the length of an STR-IC-LCS in O(mN + nM) time, which is asymptotically faster than Deorowicz’s O(MN) algorithm when strings are compressible via RLE.
  • The algorithm achieves this speedup by reducing the number of interval combinations to O(mN + nM) using structural properties of minimal C-intervals and the cDP table.
  • The method supports efficient reconstruction of the actual STR-IC-LCS in O(m + n) time after preprocessing, by storing and backtracking the optimal C-interval pairs.
  • The approach is applicable beyond artificial cases, as RLE naturally arises in music, time-series data (e.g., SAX), and other domains where data is discretized and repetitive.
  • The algorithm maintains correctness and efficiency even when |RLE(C)| = 1, with the same time complexity.
  • Empirical gains are expected to be significant on compressible strings, as m ≤ M and n ≤ N always hold, and m, n can be much smaller than M, N.

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.