Optimal streaming algorithm for detecting $\ell_2$ heavy hitters in random order streams

Santhoshini Velusamy, Huacheng Yu

公開日: 2025/9/8

Abstract

Given a stream $x_1,x_2,\dots,x_n$ of items from a Universe $U$ of size $\mathsf{poly}(n)$, and a parameter $\epsilon>0$, an item $i\in U$ is said to be an $\ell_2$ heavy hitter if its frequency $f_i$ in the stream is at least $\sqrt{\epsilon F_2}$, where $F_2=\sqrt{\sum_{i\in U} f_i^2}$. The classical $\mathsf{CountSketch}$ algorithm due to Charikar, Chen, and Farach-Colton [2004], was the first algorithm to detect $\ell_2$ heavy hitters using $O\left(\frac{\log^2 n}{\epsilon}\right)$ bits of space, and their algorithm is optimal for streams with deletions. For insertion-only streams, Braverman, Chestnut, Ivkin, Nelson, Wang, and Woodruff [2017] gave the $\mathsf{BPTree}$ algorithm which requires only $O\left(\frac{\log(1/\epsilon)}{\epsilon}\log n \right)$ space. Note that any algorithm requires at least $O\left(\frac{1}{\epsilon} \log n\right)$ space to output $O(1/\epsilon)$ heavy hitters in the worst case. So for constant $\epsilon$, the space usage of the $\mathsf{BPTree}$ algorithm is optimal but their bound could be sub-optimal for $\epsilon=o(1)$. In this work, we show that for random order streams, where the stream elements can be adversarial but their order of arrival is uniformly random, it is possible to achieve the optimal space bound of $O\left(\frac{1}{\epsilon} \log n\right)$ for every $\epsilon = \Omega\left(\frac{1}{2^{\sqrt{\log n}}}\right)$. We also show that for partially random order streams where only the heavy hitters are required to be uniformly distributed in the stream, it is possible to achieve the same space bound, but with an additional assumption that the algorithm is given a constant approximation to $F_2$ in advance.

Optimal streaming algorithm for detecting $\ell_2$ heavy hitters in random order streams | SummarXiv | SummarXiv