English

How to answer a small batch of RMQs or LCA queries in practice

Data Structures and Algorithms 2017-05-15 v1

Abstract

In the Range Minimum Query (RMQ) problem, we are given an array AA of nn numbers and we are asked to answer queries of the following type: for indices ii and jj between 00 and n1n-1, query RMQA(i,j)\text{RMQ}_A(i,j) returns the index of a minimum element in the subarray A[i..j]A[i..j]. Answering a small batch of RMQs is a core computational task in many real-world applications, in particular due to the connection with the Lowest Common Ancestor (LCA) problem. With small batch, we mean that the number qq of queries is o(n)o(n) and we have them all at hand. It is therefore not relevant to build an Ω(n)\Omega(n)-sized data structure or spend Ω(n)\Omega(n) time to build a more succinct one. It is well-known, among practitioners and elsewhere, that these data structures for online querying carry high constants in their pre-processing and querying time. We would thus like to answer this batch efficiently in practice. With efficiently in practice, we mean that we (ultimately) want to spend n+O(q)n + \mathcal{O}(q) time and O(q)\mathcal{O}(q) space. We write nn to stress that the number of operations per entry of AA should be a very small constant. Here we show how existing algorithms can be easily modified to satisfy these conditions. The presented experimental results highlight the practicality of this new scheme. The most significant improvement obtained is for answering a small batch of LCA queries. A library implementation of the presented algorithms is made available.

Keywords

Cite

@article{arxiv.1705.04589,
  title  = {How to answer a small batch of RMQs or LCA queries in practice},
  author = {Mai Alzamel and Panagiotis Charalampopoulos and Costas S. Iliopoulos and Solon P. Pissis},
  journal= {arXiv preprint arXiv:1705.04589},
  year   = {2017}
}

Comments

Accepted to IWOCA 2017