English

Rank-Select Indices Without Tears

Data Structures and Algorithms 2017-09-08 v1

Abstract

A rank-select index for a sequence B=(b1,,bn)B=(b_1,\ldots,b_n) of nn bits is a data structure that, if provided with an operation to access Θ(logn)\Theta(\log n) arbitrary consecutive bits of BB in constant time (thus BB is stored outside of the data structure), can compute rankB(j)=i=1jbi\mathit{rank}_B(j)=\sum_{i=1}^j b_i for given j{0,,n}j\in\{0,\ldots,n\} and selectB(k)=min{j:rankB(j)k}\mathit{select}_B(k)=\min\{j:\mathit{rank}_B(j)\ge k\} for given k{1,,i=1nbi}k\in\{1,\ldots,\sum_{i=1}^n b_i\}. We describe a new rank-select index that, like previous rank-select indices, occupies O(nloglogn/logn)O(n\log\log n/\log n) bits and executes rank\mathit{rank} and select\mathit{select} queries in constant time. Its derivation is intended to be particularly easy to follow and largely free of tedious low-level detail, its operations are given by straight-line code, and we show that it can be constructed in O(n/logn)O(n/\log n) time.

Keywords

Cite

@article{arxiv.1709.02377,
  title  = {Rank-Select Indices Without Tears},
  author = {Tim Baumann and Torben Hagerup},
  journal= {arXiv preprint arXiv:1709.02377},
  year   = {2017}
}
R2 v1 2026-06-22T21:36:21.643Z