Content deleted Content added
m Open access bot: arxiv added to citation with #oabot. |
Citation bot (talk | contribs) Alter: journal. Add: authors 1-1. Removed parameters. Some additions/deletions were parameter name changes. | Use this bot. Report bugs. | Suggested by Abductive | via #UCB_webform 155/1912 |
||
Line 10:
For example, for <math>f = \sum</math> and <math>A[1,n]</math> an array of numbers, the range query <math>\sum_{i,j} A</math> computes <math>\sum A[i,j] = (a_i+\ldots + a_j)</math>, for any <math>1 \leq i \leq j \leq n</math>. These queries may be answered in [[constant time]] and using <math>O(n)</math> extra space by calculating the sums of the first {{mvar|i}} elements of {{mvar|A}} and storing them into an auxiliary array {{mvar|B}}, such that <math>B[i]</math> contains the sum of the first {{mvar|i}} elements of {{mvar|A}} for every <math>0\leq i\leq n</math>. Therefore, any query might be answered by doing <math>\sum A[i,j] = B[j] - B[i-1]</math>.
This strategy may be extended for every [[Group (mathematics)|group]] operator {{mvar|f}} where the notion of <math>f^{-1}</math> is well defined and easily computable.<ref name="morin">{{cite journal|
==Examples==
Line 18:
{{main|Range minimum query}}
When the function of interest in a range query is a [[semigroup]] operator, the notion of <math>f^{-1}</math> is not always defined, so the strategy in the previous section does not work. [[Andrew Yao]] showed<ref name="yao">{{cite journal|last=Yao, A. C|title=Space-Time Tradeoff for Answering Range Queries|journal=
There are some semigroup operators that admit slightly better solutions. For instance when <math>f\in \{\max,\min\}</math>. Assume <math> f = \min</math> then <math>\min(A[1..n])</math> returns the index of the [[minimum]] element of <math>A[1..n]</math>. Then <math>\min_{i,j}(A)</math> denotes the corresponding minimum range query. There are several data structures that allow to answer a range minimum query in <math>O(1)</math> time using a preprocessing of time and space <math>O(n)</math>. One such solution is based on the equivalence between this problem and the [[lowest common ancestor]] problem.
Line 41:
|}
Recently Jørgensen et al. proved a lower bound on the [[cell-probe model]] of <math>\Omega\left(\tfrac{\log n}{\log (S w/n)}\right)</math> for any data structure that uses {{mvar|S}} cells.<ref name=jorgensen>{{cite journal|
===Median===
This particular case is of special interest since finding the [[median]] has several applications.<ref name=heriel>{{cite journal|
There have been studied two variants of this problem, the [[offline algorithm|offline]] version, where all the ''k'' queries of interest are given in a batch, and a version where all the preprocessing is done up front. The offline version can be solved with <math>O(n\log k + k \log n)</math> time and <math>O(n\log k)</math> space.
The following pseudocode of the [[Quickselect|quickselect algorithm]] shows how to find the element of rank {{mvar|r}} in <math>A[i,j]</math> an unsorted array of distinct elements, to find the range medians we set <math>r=\frac{j-i}{2}</math>.<ref name="ethpaper">{{cite journal|
rangeMedian(A, i, j, r) {
Line 75:
==Related problems==
All the problems described above have been studied for higher dimensions as well as their dynamic versions. On the other hand, range queries might be extended to other data structures like [[Tree (data structure)|trees]],<ref name="morin kranakis">{{cite journal|first1=P|last1=Bose|author1-link=Jit Bose|first2=E.|last2=Kranakis|first3=P.|last3=Morin|author3-link= Pat Morin |first4=Y.|last4=Tang|title=Approximate range mode and range median queries|journal=In Proceedings of the 22nd Symposium on Theoretical Aspects of Computer Science (STACS 2005),
== See also ==
|