Given a text, rank and select queries return the number of occurrences of a character up to a position (rank) or the position of a character with a given rank (select). These queries have applications in, e.g., compression, computational geometry, and pattern matching in the form of the backwards search -- the backbone of many compressed full-text indices. A wavelet tree is a compact data structure that for a text of length $n$ over an alphabet of size $\sigma$ requires only $n\lceil\log\sigma\rceil(1+o(1))$ bits of space and can answer rank and select queries in $\Theta(\log \sigma)$ time. Wavelet trees are used in the applications described above. In this paper, we show how to improve query performance of wavelet trees by using a 4-ary tree instead of a binary tree as basis of the wavelet tree. To this end, we present a space-efficient rank and select data structure for quad vectors. The 4-ary tree layout of a wavelet tree helps to halve the number of cache misses during queries and thus reduces the query latency. Our experimental evaluation shows that our 4-ary wavelet tree can improve the latency of rank and select queries by a factor of $\approx 2$ compared to the wavelet tree implementations contained in the widely used Succinct Data Structure Library (SDSL).
翻译:给定一段文本,rank查询返回某个字符在特定位置之前的出现次数,select查询返回具有指定rank的字符的位置。这些查询在压缩、计算几何及模式匹配(例如反向搜索——许多压缩全文索引的核心技术)中具有应用。小波树是一种紧凑数据结构,对于长度为$n$、字母表大小为$\sigma$的文本,仅需$n\lceil\log\sigma\rceil(1+o(1))$比特空间,并能在$\Theta(\log \sigma)$时间内回答rank和select查询。小波树已广泛应用于上述场景。本文通过采用4叉树而非二叉树作为小波树的基础结构,展示了如何提升小波树的查询性能。为此,我们提出了一种面向四阶向量的空间高效rank和select数据结构。小波树的4叉树布局有助于将查询过程中的缓存缺失次数减半,从而降低查询延迟。实验评估表明,与广泛使用的Succinct数据结构库(SDSL)中的小波树实现相比,我们的4叉小波树可将rank和select查询延迟提升约2倍。