English

Tight Better-Than-Worst-Case Bounds for Element Distinctness and Set Intersection

Data Structures and Algorithms 2025-11-06 v1

Abstract

The element distinctness problem takes as input a list II of nn values from a totally ordered universe and the goal is to decide whether II contains any duplicates. It is a well-studied problem with a classical worst-case Ω(nlogn)\Omega(n \log n) comparison-based lower bound by Fredman. At first glance, this lower bound appears to rule out any algorithm more efficient than the naive approach of sorting II and comparing adjacent elements. However, upon closer inspection, the Ω(nlogn)\Omega(n \log n) bound does not apply if the input has many duplicates. We therefore ask: Are there comparison-based lower bounds for element distinctness that are sensitive to the amount of duplicates in the input? To address this question, we derive instance-specific lower bounds. For any input instance II, we represent the combinatorial structure of the duplicates in II by an undirected graph G(I)G(I) that connects identical elements. Each such graph GG is a union of cliques, and we study algorithms by their worst-case running time over all inputs II' with G(I)GG(I') \cong G. We establish an adversarial lower bound showing that, for any deterministic algorithm A\mathcal{A}, there exists a graph GG and an algorithm A\mathcal{A}' that, for all inputs II with G(I)GG(I) \cong G, is a factor O(loglogn)O(\log \log n) faster than A\mathcal{A}. Consequently, no deterministic algorithm can be o(loglogn)o(\log \log n)-competitive for all graphs GG. We complement this with an O(loglogn)O(\log \log n)-competitive deterministic algorithm, thereby obtaining tight bounds for element distinctness that go beyond classical worst-case analysis. We subsequently study the related problem of set intersection. We show that no deterministic set intersection algorithm can be o(logn)o(\log n)-competitive, and provide an O(logn)O(\log n)-competitive deterministic algorithm. This shows a separation between element distinctness and the set intersection problem.

Keywords

Cite

@article{arxiv.2511.02954,
  title  = {Tight Better-Than-Worst-Case Bounds for Element Distinctness and Set Intersection},
  author = {Ivor van der Hoog and Eva Rotenberg and Daniel Rutschmann},
  journal= {arXiv preprint arXiv:2511.02954},
  year   = {2025}
}
R2 v1 2026-07-01T07:21:56.975Z