For over 20 years, the Greenwald-Khanna (GK) algorithm has served as the gold standard for estimating quantiles in data streams. By using $O(\frac{1}{\varepsilon} \log \varepsilon N)$ space, it allowed researchers to approximate the distribution of massive datasets with high precision. However, a fundamental theoretical question remained: is this logarithmic dependence on the stream size $N$ truly necessary, or could a more clever algorithm achieve constant space relative to $N$?
Recent research has finally settled this long-standing open question. The paper proves that the GK algorithm's bound is "tight," meaning it is mathematically impossible for any deterministic, comparison-based algorithm to perform better. This result establishes that memory usage must grow logarithmically with the stream size, providing a definitive limit on the efficiency of streaming quantile summaries.
The Challenge of Streaming Quantiles
In big data applications, understanding the "shape" of a distribution—such as finding the 99th percentile of network latency or the median sensor reading—is critical. In a streaming context, we cannot store every item; we must use a quantile summary.
These data structures process a stream of $N$ items and allow users to query any quantile $\phi$ (where $0 \le \phi \le 1$) with an error guarantee of $\varepsilon$. For a query of the median ($\phi = 0.5$), the algorithm must return an item whose actual rank in the sorted stream is between $(0.5 - \varepsilon)N$ and $(0.5 + \varepsilon)N$. The core research question has always been whether the memory required for this guarantee must scale with $N$, or if it can remain constant, depending only on the precision $\varepsilon$.
The Adversarial Proof Method
To prove the lower bound, the authors employed a sophisticated adversarial construction. Rather than attempting to design a better algorithm, they acted as an "adversary" designed to break any possible comparison-based algorithm.
Indistinguishable Streams and the Gap Argument
The proof centers on constructing two distinct input streams, $\pi$ and $\varrho$. These streams are meticulously designed so that any comparison-based algorithm—which only knows if one item is larger than another but not the numerical distance between them—will end up in the exact same internal memory state after processing either stream.
As shown in the figure above, while the algorithm perceives the streams as identical, the adversary ensures there is a massive "gap" in the actual ranks of the items between the two streams. If this gap exceeds $2\varepsilon N$, the algorithm is guaranteed to fail on at least one of the streams because it cannot distinguish which rank is correct.
Recursive Construction
The breakthrough lies in a recursive strategy. By nesting these adversarial streams within one another, the authors force the algorithm into a dilemma: it must either use more memory to "remember" specific items or face an ever-widening gap of uncertainty. This recursive nesting is what mathematically necessitates the logarithmic dependence on $N$ (specifically $\log \varepsilon N$), perfectly matching the known upper bound of the GK algorithm.
Key Insights and Results
This research provides several critical insights into the limits of streaming algorithms:
- The End of Constant Space: For years, researchers hoped for a deterministic algorithm where space was a function of $\varepsilon$ alone, independent of $N$. This paper definitively rules that out for all comparison-based methods.
- The Space-Gap Inequality: The authors formalized a relationship between average memory usage and maximum uncertainty. To keep the rank gap within the required $\varepsilon N$ error margin, the algorithm must pay a memory price that scales with the number of recursive levels in the stream.
- The Tight Bound: The paper proves a lower bound of $\Omega(\frac{1}{\varepsilon} \log \varepsilon N)$ words of memory. This matches the 2001 Greenwald-Khanna algorithm, closing the theoretical gap that existed for two decades.
- Biased Quantiles: For "biased" quantiles (requiring higher accuracy at the extremes, like the 99.9th percentile), the authors improved the lower bound to $\Omega(\frac{1}{\varepsilon} \log^2 \varepsilon N)$.
Limitations and Future Directions
While this proof is comprehensive for comparison-based algorithms, it does not apply to algorithms that utilize the numerical properties of data (such as q-digest). Such algorithms can sometimes achieve space independent of $N$, though they typically introduce a dependency on the size of the value universe ($U$).
Additionally, while the standard GK algorithm is now proven optimal, a "greedy" variant of the algorithm often performs better in empirical tests. Whether this greedy version admits a simpler proof of optimality remains an open question for future theoretical refinement.
Summary updated