English

Differentially Private Substring and Document Counting with Near-Optimal Error

Data Structures and Algorithms 2026-03-27 v2 Cryptography and Security

Abstract

For databases consisting of many text documents, one of the most fundamental data analysis tasks is counting (i) how often a pattern appears as a substring in the database (substring counting) and (ii) how many documents in the collection contain the pattern as a substring (document counting). If such a database contains sensitive data, it is crucial to protect the privacy of individuals in the database. Differential privacy is the gold standard for privacy in data analysis. It gives rigorous privacy guarantees, but comes at the cost of yielding less accurate results. In this paper, we carry out a theoretical study of substring and document counting under differential privacy. We propose a data structure storing ϵ\epsilon-differentially private counts for all possible query patterns with a maximum additive error of O(polylog(nΣ))O(\ell\cdot\mathrm{polylog}(n\ell|\Sigma|)), where \ell is the maximum length of a document in the database, nn is the number of documents, and Σ|\Sigma| is the size of the alphabet. We also improve the error bound for document counting with (ϵ,δ)(\epsilon, \delta)-differential privacy to O(polylog(nΣ))O(\sqrt{\ell}\cdot\mathrm{polylog}(n\ell|\Sigma|)). We show that our additive errors for substring counting and document counting are optimal up to an O(polylog(n))O(\mathrm{polylog}(n\ell)) factor both for ϵ\epsilon-differential privacy and (ϵ,δ)(\epsilon, \delta)-differential privacy. Our data structures immediately lead to improved algorithms for related problems, such as privately mining frequent substrings and q-grams. Additionally, we develop a new technique of independent interest for differentially privately computing a general class of counting functions on trees.

Keywords

Cite

@article{arxiv.2412.13813,
  title  = {Differentially Private Substring and Document Counting with Near-Optimal Error},
  author = {Giulia Bernardini and Philip Bille and Inge Li Gørtz and Teresa Anna Steiner},
  journal= {arXiv preprint arXiv:2412.13813},
  year   = {2026}
}

Comments

42 pages, 3 figures. A preliminary version of this paper appeared at PODS2025. This replacement contains new lower bounds

R2 v1 2026-06-28T20:40:25.376Z