Table of Contents
Fetching ...

Sorted Range Reporting and Range Minima Queries

Waseem Akram, Sanjeev Saxena

TL;DR

The paper addresses reporting the k smallest elements from a subarray A[i:j] in sorted order. It introduces a linear-space data structure that, after $O(n)$ preprocessing, answers queries in $O(k\log k)$ time by using RMQ to extract minima and a binary heap to emit elements in non-decreasing order, reporting outputs incrementally. This provides the only other optimal trade-off to the known $O(k)$-time solution, and is presented as simple and practical, with an extremely straightforward RMQ variant discussed for near-linear preprocessing. For the special case $k=n$, the approach sorts the entire array in $O(n\log n)$ total time, highlighting its theoretical grounding and practical relevance, with open questions remaining for dynamic updates.

Abstract

Given an array A[1: n] of n elements drawn from an ordered set, the sorted range selection problem is to build a data structure that can be used to answer the following type of queries efficiently: Given a pair of indices i, j $ (1\le i\le j \le n)$, and a positive integer k, report the k smallest elements from the sub-array A[i: j] in order. Brodal et al. (Brodal, G.S., Fagerberg, R., Greve, M., and L{ó}pez-Ortiz, A., Online sorted range reporting. Algorithms and Computation (2009) pp. 173--182) introduced the problem and gave an optimal solution. After O(n log n) time for preprocessing, the query time is O(k). The space used is O(n). In this paper, we propose the only other possible optimal trade-off for the problem. We present a linear space solution to the problem that takes O(k log k) time to answer a range selection query. The preprocessing time is O(n). Moreover, the proposed algorithm reports the output elements one by one in non-decreasing order. Our solution is simple and practical. We also describe an extremely simple method for range minima queries (most of whose parts are known) which takes al most (but not exactly) linear time. We believe that this method may be, in practice, faster and easier to implement in most cases.

Sorted Range Reporting and Range Minima Queries

TL;DR

The paper addresses reporting the k smallest elements from a subarray A[i:j] in sorted order. It introduces a linear-space data structure that, after preprocessing, answers queries in time by using RMQ to extract minima and a binary heap to emit elements in non-decreasing order, reporting outputs incrementally. This provides the only other optimal trade-off to the known -time solution, and is presented as simple and practical, with an extremely straightforward RMQ variant discussed for near-linear preprocessing. For the special case , the approach sorts the entire array in total time, highlighting its theoretical grounding and practical relevance, with open questions remaining for dynamic updates.

Abstract

Given an array A[1: n] of n elements drawn from an ordered set, the sorted range selection problem is to build a data structure that can be used to answer the following type of queries efficiently: Given a pair of indices i, j , and a positive integer k, report the k smallest elements from the sub-array A[i: j] in order. Brodal et al. (Brodal, G.S., Fagerberg, R., Greve, M., and L{ó}pez-Ortiz, A., Online sorted range reporting. Algorithms and Computation (2009) pp. 173--182) introduced the problem and gave an optimal solution. After O(n log n) time for preprocessing, the query time is O(k). The space used is O(n). In this paper, we propose the only other possible optimal trade-off for the problem. We present a linear space solution to the problem that takes O(k log k) time to answer a range selection query. The preprocessing time is O(n). Moreover, the proposed algorithm reports the output elements one by one in non-decreasing order. Our solution is simple and practical. We also describe an extremely simple method for range minima queries (most of whose parts are known) which takes al most (but not exactly) linear time. We believe that this method may be, in practice, faster and easier to implement in most cases.

Paper Structure

This paper contains 6 sections, 3 theorems, 1 equation, 1 algorithm.

Key Result

theorem 1

An array $A[1:n]$ of $n$ elements drawn from a totally ordered set can be preprocessed so that given a pair of indices $i,j$ with $1 \le i\le j\le n$ and a parameter $k$, we can report the $k$ smallest elements in the subarray $A[i:j]$ in $O(k\log k)$ time. The preprocessing takes $O(n)$ space and

Theorems & Definitions (6)

  • remark 1
  • remark 2
  • theorem 1
  • remark 3
  • lemma 1
  • corollary 1