Sliding window order statistics in sublinear space

Dhruv RohatgiarXiv 2018

Introduction

In the analysis of massive data streams, the sliding window model is a standard paradigm for processing the most recent $K$ elements—such as the last hour of stock prices or network packets. A significant challenge in this field is the "linear space barrier." Previous research, notably by Datar et al. (2002), proved that computing basic statistics like the minimum value in a sliding window requires $\Omega(K)$ space in a single-pass model. When the window size is large relative to available RAM, these computations become infeasible.

This paper investigates whether this barrier can be broken by moving from a single-pass to a multi-pass streaming model. By allowing the algorithm to traverse the data a small number of times—a common capability when data is stored on external memory or disk—the author demonstrates that space complexity can be reduced from linear to sublinear.

Methodology: Leveraging Monotonicity

The author's approach relies on the fundamental structural properties of order statistics, specifically the concept of monotonicity.

1. Monotonicity of Minima

In a sliding window, as the window boundaries move forward, the index of the minimum element never moves backward. If the minimum of the first window is at index 10, the minimum of the subsequent window cannot be at index 9. This property allows the algorithm to track the "evolution" of the minimum efficiently across passes.

2. The Two-Pass Strategy for Minima

To solve the sliding window minimum problem in sublinear space, the paper proposes a two-pass strategy:

  • Pass 1 (Landmark Identification): The algorithm computes the exact minimum for a "sparse" set of windows (e.g., every $\sqrt{N}$ windows). These results act as landmarks.
  • Pass 2 (Interpolation): Using the landmarks from the first pass, the algorithm only needs to maintain a small number of candidate minimums to fill in the gaps for all intermediate windows.

This process is facilitated by a monotonic queue, a specialized data structure that maintains elements in a sorted state to allow for amortized constant-time updates and queries.

3. Near-Monotonicity for $l^{th}$-Smallest Elements

For the more complex problem of finding the $l^{th}$-smallest element, the author introduces "near-monotonicity." While the index of a specific $l^{th}$-smallest element might fluctuate, the set of indices for the $l$ smallest elements moves forward in a predictable, elementwise non-decreasing way. By extending the landmark strategy, the paper provides an algorithm that solves the $l^{th}$-smallest problem using $l+1$ passes.

Key Insights and Results

The Power of the Second Pass

The transition from one pass to two passes is transformative for space complexity. It shifts the requirement from linear ($N$) to sublinear ($\tilde{O}(\sqrt{N})$). The paper proves that $\Omega(\sqrt{N})$ is essentially the best possible space complexity for the sliding window minimum problem for any constant number of passes.

The Hardness of Frequency Statistics

A surprising insight is that while order statistics (like the minimum) become easier with multiple passes, frequency-based statistics do not. The author proves that finding the Majority element (the element appearing more than 50% of the time) remains hard, requiring $\Omega(N)$ space regardless of the number of passes, provided the results are output in a single linear scan. This highlights the unique structural advantages of order statistics.

Summary of Complexity

  • Sliding-Min: Solvable in $\tilde{O}(\sqrt{N})$ space using 2 input passes and 1 output pass.
  • $l^{th}$-Smallest: Solvable in $\tilde{O}(l^{3/2}\sqrt{N})$ space using $l+1$ input passes.
  • Communication Complexity: The paper also provides a $p$-round algorithm for the communication model (splitting data between two parties) that uses $\tilde{O}(p N^{1/p})$ bits.

Limitations and Future Work

While the paper successfully breaks the linear space barrier, several theoretical gaps remain:

  • Logarithmic Factors: There is a small gap between the upper bound ($\tilde{O}(\sqrt{N})$) and the lower bound ($\Omega(\sqrt{N})$). The author conjectures that the lower bound can be tightened to include these logarithmic factors.
  • Dependence on $l$: The space complexity for the $l^{th}$-smallest element grows with $l$. Future research could investigate if this dependence can be further optimized.
  • Output Pass Constraints: The current results assume a single output pass (writing answers in order). Allowing multiple output passes might enable even more efficient algorithms, though this remains an open question in the field.

Summary updated

BibTeX
@misc{rohatgi2018sliding,
  author = {Dhruv Rohatgi},
  title = {{Sliding window order statistics in sublinear space}},
  year = {2018},
  eprint = {1807.04400},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1807.04400},
}
Figure