English

Small Uncolored and Colored Choice Dictionaries

Data Structures and Algorithms 2018-09-21 v1

Abstract

A choice dictionary can be initialized with a parameter nNn\in\mathbb{N} and subsequently maintains an initially empty subset SS of {1,,n}\{1,\ldots,n\} under insertion, deletion, membership queries and an operation choice\textit{choice} that returns an arbitrary element of SS. The choice dictionary is fundamental in space-efficient computing and has numerous applications. The best previous choice dictionary can be initialized with nn and tNt\in\mathbb{N} and subsequently executes all operations in O(t)O(t) time and occupies n+O(n(t/w)t+logn)n+O(n({t/w})^t+\log n) bits on a word RAM with a word length of w=Ω(logn)w=\Omega(\log n) bits. We describe a new choice dictionary that executes all operations in constant time and, in addition to the space needed to store the integer nn, occupies only n+1n+1 bits, which is shown to be optimal if w=o(n)w=o(n). A generalization of the choice dictionary called a colored choice dictionary is initialized with cNc\in\mathbb{N} in addition to nn and subsequently maintains a semipartition (S0,,Sc1)(S_0,\ldots,S_{c-1}) of {1,,n}\{1,\ldots,n\} under the operations setcolor(j,)\textit{setcolor}(j,\ell), which moves \ell from its current subset to SjS_j, color()\textit{color}(\ell), which returns the unique j{0,,c1}j\in\{0,\ldots,c-1\} with Sj\ell\in S_j, and choice(j)\textit{choice}(j), which returns an arbitrary element of SjS_j. We describe new colored choice dictionaries that, if initialized with constant cc, execute setcolor\textit{setcolor}, color\textit{color} and choice\textit{choice} in constant time and occupy nlog2 ⁣c+1n\log_2\!c+1 bits plus the space needed to store nn if cc is a power of 2, and at most nlog2 ⁣c+nϵn\log_2\!c+n^\epsilon bits in general, for arbitrary fixed ϵ>0\epsilon>0. We also study the possibility of iterating over the set SS or over SjS_j for given j{0,,c1}j\in\{0,\ldots,c-1\} and an application of this to breadth-first search.

Cite

@article{arxiv.1809.07661,
  title  = {Small Uncolored and Colored Choice Dictionaries},
  author = {Torben Hagerup},
  journal= {arXiv preprint arXiv:1809.07661},
  year   = {2018}
}
R2 v1 2026-06-23T04:12:49.098Z