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

**Authors:** Mai Alzamel, Panagiotis Charalampopoulos, Costas S. Iliopoulos, Solon, P. Pissis

arXiv: 1705.04589 · 2017-05-15

## TL;DR

This paper presents practical algorithms for efficiently answering small batches of RMQ and LCA queries, significantly reducing preprocessing time and constants, with experimental validation and available implementation.

## Contribution

It introduces modified algorithms tailored for small batch RMQ and LCA queries, optimizing for practical efficiency and low constants, unlike traditional large-structure methods.

## Key findings

- Achieves near-linear total time for small batch queries
- Reduces constants in preprocessing and querying phases
- Demonstrates improved practical performance in experiments

## Abstract

In the Range Minimum Query (RMQ) problem, we are given an array $A$ of $n$ numbers and we are asked to answer queries of the following type: for indices $i$ and $j$ between $0$ and $n-1$, query $\text{RMQ}_A(i,j)$ returns the index of a minimum element in the subarray $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 $q$ of queries is $o(n)$ and we have them all at hand. It is therefore not relevant to build an $\Omega(n)$-sized data structure or spend $\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 + \mathcal{O}(q)$ time and $\mathcal{O}(q)$ space. We write $n$ to stress that the number of operations per entry of $A$ 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.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1705.04589/full.md

## Figures

7 figures with captions in the complete paper: https://tomesphere.com/paper/1705.04589/full.md

## References

20 references — full list in the complete paper: https://tomesphere.com/paper/1705.04589/full.md

---
Source: https://tomesphere.com/paper/1705.04589