English

Huffman-Bucket Sketch: A Simple $O(m)$ Algorithm for Cardinality Estimation

Data Structures and Algorithms 2026-03-12 v1

Abstract

We introduce the Huffman-Bucket Sketch (HBS), a simple, mergeable data structure that losslessly compresses a HyperLogLog (HLL) sketch with mm registers to optimal space O(m+logn)O(m+\log n) bits, with amortized constant-time updates, acting as a drop-in replacement for HLL that retains mergeability and substantially reduces memory requirements. We partition registers into small buckets and encode their values with a global Huffman codebook derived from the strongly concentrated HLL rank distribution, using the current cardinality estimate for determining the mode of the distribution. We prove that the Huffman tree needs rebuilding only O(logn)O(\log n) times over a stream, roughly when cardinality doubles. The framework can be extended to other sketches with similar strongly concentrated distributions. We provide preliminary numerical evidence that suggests that HBS is practical and can potentially be competitive with state-of-the-art in practice.

Cite

@article{arxiv.2603.10930,
  title  = {Huffman-Bucket Sketch: A Simple $O(m)$ Algorithm for Cardinality Estimation},
  author = {Matti Karppa},
  journal= {arXiv preprint arXiv:2603.10930},
  year   = {2026}
}

Comments

13+12 pages, 3 figures

R2 v1 2026-07-01T11:14:56.435Z