Sub topic 15
Why Quadratic Time Is Hard to Beat
This chapter assumes you know Big-O notation, the O(mn) dynamic programming table from earlier chapters, and roughly what the Boolean satisfiability problem (SAT) is. Researchers have tried for decades to find a faster general algorithm for edit distance and have not found one. Complexity theory now gives a strong reason to think no such algorithm exists.
The Gap Between Upper and Lower Bounds
For two strings of length n, the table algorithm takes Θ(n²) time. The best known improvement is the Masek–Paterson "Four Russians" method from 1980, which runs in O(n²/log n) time for a fixed alphabet. It splits the table into small blocks and looks up precomputed answers for them. The only lower bound anyone can prove without extra assumptions is Ω(n), the time needed to read the input. Unconditional proofs leave a wide gap between those two bounds.
The Strong Exponential Time Hypothesis
The Strong Exponential Time Hypothesis (SETH) is a conjecture about SAT. It says that for every ε > 0 there is some k such that k-SAT on N variables cannot be solved in O(2^((1−ε)N)) time. In plain terms, brute-force search over all assignments is essentially optimal. SETH is unproven, but decades of SAT-solver research have not refuted it.
The Reduction
In 2015, Backurs and Indyk proved that an algorithm computing edit distance in O(n^(2−ε)) time, for any constant ε > 0, would refute SETH. An algorithm with that kind of running time is called strongly subquadratic. The proof goes through the Orthogonal Vectors problem, which asks whether two sets of 0/1 vectors contain a pair with dot product zero.
The construction turns each vector into a short "gadget" string. The gadgets are built so that the edit distance between the two combined strings drops below a fixed threshold exactly when an orthogonal pair exists. A fast edit distance algorithm would therefore solve Orthogonal Vectors fast, and Williams (2005) showed that this in turn would solve k-SAT fast.
Later work by Abboud, Hansen, Vassilevska Williams, and Williams (2016) went further. Even an O(n²/log^c n) algorithm for large enough c would imply new circuit lower bounds, results that complexity theorists consider far out of reach.
Practical Escape Routes
| Approach | Time | What you give up |
|---|---|---|
| Full DP table | O(mn) | Nothing |
| Banded, threshold k | O(k·n) | Exact answer only when the distance is at most k |
| Bit-parallel (Myers) | O(⌈m/w⌉·n) | A constant factor only, still quadratic |
| Four Russians | O(n²/log n) | Complexity, small practical gain |
| Constant-factor approximation | Near-linear | Exactness |
Andoni and Nosatzki (2020) gave a constant-factor approximation in near-linear time. That result shows the quadratic barrier applies only to exact computation. In practice, most systems avoid the worst case by bounding the distance, filtering candidates first, or accepting approximate answers.
Exercise
A new paper claims an exact edit distance algorithm running in O(n^2 / log^2 n) time. Does this contradict SETH? What about O(n^1.99)?
Show answer
O(n^2 / log^2 n) does not contradict SETH, because it is not O(n^(2-ε)) for any constant ε > 0. It would still be surprising given the circuit lower bound results for large polylog savings. O(n^1.99) is strongly subquadratic (ε = 0.01), so it would refute SETH.
Exercise
You compare two DNA reads of length 1,000,000 and only care whether their distance is at most 500. Roughly how many cell computations does the full table need, and how many does a banded computation need?
Show answer
The full table needs about 10^12 cells. A band of width 2k+1 = 1001 needs about 1001 × 10^6 ≈ 10^9 cells, roughly 1000 times fewer.