Near-Optimal Quantum Algorithms for Bounded Edit Distance and Lempel-Ziv Factorization
Daniel Gibney, Ce Jin, Tomasz Kociumaka, Sharma V. Thankachan
Abstract
Measuring sequence similarity and compressing texts are among the most fundamental tasks in string algorithms. In this work, we develop near-optimal quantum algorithms for the central problems in these two areas: computing the edit distance of two strings [Levenshtein, 1965] and building the Lempel-Ziv factorization of a string [Ziv & Lempel, 1977], respectively.
Classically, the edit distance of two length-n strings can be computed in O(n 2 ) time and there is little hope for a significantly faster algorithm: an O(n 2-ϵ )-time procedure would falsify the Strong Exponential Time Hypothesis. Quantum computers might circumvent this lower bound, but even 3-approximation of edit distance is not known to admit an O(n 2-ϵ )-time quantum algorithm. In the bounded setting, where the complexity is parameterized by the value k of the edit distance, there is an O(n + k 2 )-time classical algorithm [Myers, 1986;Landau & Vishkin, 1988], which is optimal (up to sub-polynomial factors and conditioned on SETH) as a function of n and k. Our first main contribution is a quantum O( √ nk + k 2 )-time algorithm that uses O( √ nk) queries, where the O(•) notation hides polylogarithmic factors. This query complexity is unconditionally optimal, and any significant improvement in the time complexity would break the quadratic barrier for the unbounded setting. Interestingly, our divide-and-conquer quantum algorithm reduces the bounded edit distance problem to the special case where the two input strings have small Lempel-Ziv factorizations. Then, it combines our quantum LZ compression algorithm with a classical subroutine computing edit distance between compressed strings. The LZ factorization problem can be classically solved in O(n) time, which is unconditionally optimal in the quantum setting (even for computing just the size z of the factorization). We can, however, hope for a quantum speedup if we parameterize the complexity in terms of z. Already a generic oracle identification algorithm [Kothari 2014] yields the optimal query complexity of O( √ nz) at the price of exponential running time. Our second main contribution is a quantum algorithm that also achieves the optimal time complexity of O( √ nz). The key insight is the introduction of a novel LZ-like factorization of size O(z log 2 n), which allows us to efficiently compute each new factor through a combination of classical and quantum algorithmic techniques. From this, we obtain the desired LZ factorization. Using existing results [Kempa & Kociumaka, 2020], we can then obtain the string's run-length encoded Burrows-Wheeler Transform (BWT)-another classical compressor [Burrows & Wheeler, 1994], and a structure for longest common extensions (LCE) queries in O(z) extra time [I, 2017;Nishimoto et al., 2016].
Lastly, we obtain efficient indexes of size O(z) for counting and reporting the occurrences of a given pattern and for supporting more general suffix array and inverse suffix array queries, based on the recent r-index [Gagie, Navarro, and Prezza, 2020]. These indexes can be constructed in O( √ nz) quantum time, which allows us to solve many fundamental problems, like longest common substring, maximal unique matches, and Lyndon factorization, in time O( √ nz).
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers5
- Faster Weighted and Unweighted Tree Edit Distance and APSP EquivalenceJakob Nogler, Adam Polak, Barna Saha, Virginia Vassilevska Williams et al.STOC 2025 · 4 citations
- Lempel-Ziv (LZ77) Factorization in Sublinear TimeDominik Kempa, Tomasz KociumakaFOCS 2024 · 2 citations
- Bounded Edit Distance: Optimal Static and Dynamic Algorithms for Small Integer WeightsEgor Gorbachev, Tomasz KociumakaSTOC 2025 · 1 citation
- On the Hardness Hierarchy for the O(n√log n) Complexity in the Word RAMDominik Kempa, Tomasz KociumakaSTOC 2025
- The Complexity of Dynamic LZ77 is ?Θ(n2/3)Itai Boneh, Shay Golan, Matan KrausSODA 2026
Builds on12
- Resolution of the Burrows-Wheeler Transform ConjectureDominik Kempa, Tomasz KociumakaFOCS 2020 · 32 citations
- Near-Optimal Quantum Algorithms for String ProblemsShyan Akmal, Ce JinSODA 2022 · 15 citations
- Does preprocessing help in fast sequence comparisons?Elazar Goldenberg, Aviad Rubinstein, Barna SahaSTOC 2020 · 15 citations
- Small-space and streaming pattern matching with editsTomasz Kociumaka, Ely Porat, Tatiana StarikovskayaFOCS 2021 · 13 citations
- An Upper Bound and Linear-Space Queries on the LZ-End ParsingDominik Kempa, Barna SahaSODA 2022 · 12 citations
Related papers
- Near-Optimal-Time Quantum Algorithms for Approximate Pattern MatchingTomasz Kociumaka, Jakob Nogler, Philip WellnitzSODA 2025 · 1 citation
- How Compression and Approximation Affect Efficiency in String Distance MeasuresArun Ganesh, Tomasz Kociumaka, Andrea Lincoln, Barna SahaSODA 2022 · 7 citations
- Optimal Algorithms for Bounded Weighted Edit DistanceAlejandro Cassis, Tomasz Kociumaka, Philip WellnitzFOCS 2023 · 4 citations
- Reducing approximate Longest Common Subsequence to approximate Edit DistanceAviad Rubinstein, Zhao SongSODA 2020 · 24 citations
- On the Communication Complexity of Approximate Pattern MatchingTomasz Kociumaka, Jakob Nogler, Philip WellnitzSTOC 2024 · 2 citations
