Average-Case Optimal Encodings and Efficient Worst-Case Indices for Element Distinctness Queries
arXiv:2608.17907
Abstract
We study the data structure version of the \emph{element distinctness problem}: preprocess an array of elements from an alphabet of size to answer \textsc{All-Distinct} queries, asking whether a given range contains only distinct elements. We first focus on \emph{uniformly random arrays}: in the encoding model, where access to the input at query time is not allowed, we prove a lower bound on the expected space; for instance, the lower bound is , , , bits for , and approximately bits for . We complement this by designing different average-case optimal encodings, supporting \textsc{All-Distinct} queries in worst-case time , , or depending on , and expected time for any . We then switch to worst-case (non-random) arrays: in the indexing model, where access to the input is allowed, we prove a cell-probe space-time tradeoff lower bound showing that any index using bits must have query time. We conclude by presenting a simple index almost matching this lower bound.
Accepted at SPIRE 2026. Full version