Skip to main content
QUICK REVIEW

[Paper Review] Pattern matching in Lempel-Ziv compressed strings: fast, simple, and deterministic

Paweł Gawrychowski|arXiv (Cornell University)|Apr 21, 2011
Algorithms and Data CompressionComputer Science13 references14 citations
TL;DR

This paper presents a deterministic, O(n log(N/n) + m) time algorithm for pattern matching in Lempel-Ziv-compressed strings, significantly improving upon the previous randomized O(n log²(N/n) + m) solution by Farach and Thorup. By transforming the LZ parse into a balanced straight-line program and efficiently computing covers, prefixes, and suffixes using suffix tree properties, the method enables fast pattern detection without decompression, achieving optimal performance for highly compressible texts.

ABSTRACT

Countless variants of the Lempel-Ziv compression are widely used in many real-life applications. This paper is concerned with a natural modification of the classical pattern matching problem inspired by the popularity of such compression methods: given an uncompressed pattern s[1..m] and a Lempel-Ziv representation of a string t[1..N], does s occur in t? Farach and Thorup gave a randomized O(nlog^2(N/n)+m) time solution for this problem, where n is the size of the compressed representation of t. We improve their result by developing a faster and fully deterministic O(nlog(N/n)+m) time algorithm with the same space complexity. Note that for highly compressible texts, log(N/n) might be of order n, so for such inputs the improvement is very significant. A (tiny) fragment of our method can be used to give an asymptotically optimal solution for the substring hashing problem considered by Farach and Muthukrishnan.

Motivation & Objective

  • To address the challenge of efficiently searching for a pattern in Lempel-Ziv-compressed text without full decompression.
  • To overcome the limitations of prior randomized algorithms with higher time complexity.
  • To develop a deterministic solution that matches or improves upon the best-known time bounds for compressed pattern matching.
  • To handle highly compressible texts where n ≪ N, ensuring the algorithm scales with compression ratio.
  • To provide a simpler, more practical alternative to complex prior methods while maintaining theoretical optimality.

Proposed method

  • Transforming the Lempel-Ziv parse into a balanced straight-line program (SLP) of size O(n log(N/n)) using the method of Charikar et al.
  • Computing covers for all nonterminals representing substrings of the pattern using a bottom-up traversal and dynamic programming.
  • Using a linear-time algorithm to compute prefix and suffix arrays for nonterminals based on their children’s covers and properties.
  • Leveraging suffix tree operations and Lemma 12 to locate substrings in constant time via integer division and power-of-two length assumptions.
  • Applying Lemma 7 to compute prefix and suffix overlaps between nonterminal strings using carefully chosen arguments and bounds.
  • Detecting pattern occurrences by checking all productions X → YZ for matches in prefix(Y) + suffix(Z), using Lemma 6 for efficient verification.

Experimental results

Research questions

  • RQ1Can a deterministic algorithm achieve O(n log(N/n) + m) time for pattern matching in Lempel-Ziv-compressed strings, improving upon the prior randomized O(n log²(N/n) + m) solution?
  • RQ2Is it possible to eliminate the quadratic dependency on pattern length m in compressed pattern matching for LZ, especially when m ≫ n?
  • RQ3Can the use of straight-line programs and suffix tree properties enable efficient, deterministic computation of string overlaps without decompression?
  • RQ4What is the theoretical lower bound for compressed pattern matching under algebraic computation models that exclude integer division?
  • RQ5How can the structure of LZ parsing be exploited to design a simple yet efficient algorithm for pattern detection in highly compressible texts?

Key findings

  • The proposed algorithm achieves a deterministic time complexity of O(n log(N/n) + m), improving upon the previous randomized O(n log²(N/n) + m) solution by Farach and Thorup.
  • The algorithm maintains the same space complexity as the prior solution, O(n log(N/n) + m), ensuring efficiency in memory usage.
  • For highly compressible texts where log(N/n) is Ω(n), the improvement is asymptotically significant, as the new bound reduces the logarithmic factor from squared to linear.
  • The method uses only basic arithmetic operations and suffix tree lookups, making it practical and implementable with simple components.
  • The algorithm is proven to be optimal under the assumption that integer division is not allowed, as a matching lower bound of Ω(n log N) holds for the algebraic computation tree model.
  • A minor variant of the method yields an asymptotically optimal solution for the substring hashing problem studied by Farach and Muthukrishnan.

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.