In this post, I will try to enumerate the range query problems that I know about. Let me know if I'm missing anything.

**The query. **Say you have *n* points in the plane, and you query for the points in an axis-parallel rectangle. What could we mean by "query"?

*existential range queries*: Is there any point in the rectangle?*counting queries*: How many points are there in the rectangle?*reporting queries*: List the points in the rectangle. Unlike the previous cases, the query time is now broken into two components: it is usually given as f(n) + k*g(n), where k is the number of output points.

Now let's assume the points have some number associated to them (a weight or a priority). Then one could ask the following natural queries:

*weighted counting*: What is the total weight of the points inside?*range min (max) query**range median query*. (Possible generalizations: selection or quantiles.)*top-k reporting: *Report just the top *k* guys, by priority (for *k* given). One may demand the output to be sorted. More stringently, one may ask the query algorithm to enumerate points sorted by priority, in time g(n) per point, until the user says "stop."

The number associated to a point can also be a "color". For instance, points could represent Irish pubs / Belgian bars / etc, and we may only want one point of each type in our output. Then the queries become:

*colored counting: *How many distinct colors are in the rectangle?*colored reporting*: List the distinct colors in the rectangle (possibly with one example point from each color).*top-k colored reporting*: If the colors are sorted by priorities (e.g. I prefer points of color 1 over points of color 2), one can then ask for the top-k distinct colors inside the rectangle.

**Dynamism.** The problem could be:

*static*: Preprocess the point set and then answer queries.*dynamic*: Insert and delete from the point set.*incremental* / *decremental*: We only insert or delete.*offline*: The sequence of operations is known in advance. This is enough for many applications to algorithms.*parametric* / *kinetic*. I confess ignorance with respect to these.

**Orthogonal range queries. **The setting from above works in any number of dimensions *d*≥1: the data set consists of *n* points in *d*-dimensional space and the query is a box [a_{1}, b_{1}]×···×[a_{d}, b_{d}]. This setup is usually called "orthogonal range queries".

We can consider the following important restrictions on the query:

*dominance queries*: the box is [0, b_{1}]×···×[0, b_{d}]. In other words, we are asking for the points dominated, coordinate-wise, by a point (b_{1}, ..., b_{d}).

*k*-*sided queries*: exactly 2*d*-*k* values in (a_{1}, a_{2}, ..., a_{d}) are zero. For instance, a 3-sided query in 2D is a rectangle with one side on the *x* axis. Dominance queries are the special case of *d*-sided queries.

**The universe. **The coordinates of the points and queries can come from the following sets:

- general universe. In the standard RAM model, we assume that the coordinates are integers that fit in a machine word.

*rank space*: the coordinates are from {1, 2, ..., *n*}. One can reduce any static problem to rank space by running 2*d* predecessor queries. Most problems can be shown to be at least as hard as predecessor search, so their complexity is precisely: "optimal cost of predecessor search" + "optimal cost for the problem in rank space". In other words, for most problems it is sufficient to solve them in rank space.

- dense universe: the points are exactly the points of the grid [1,
*n*_{1}]×···×[1, *n*_{d}] where *n*_{1}*n*_{2}···*n*_{d }= *n*. In 1D this is the same as rank space, but in 2 or more dimensions the problems are very different. (To my knowledgeable readers: Is there a standard name for this case? For counting queries people call this "the partial sums problem", but how about e.g. min queries?)

For dynamic problems, the "rank space" changes when a new coordinate value is inserted. Thus, a rank-space solution must support a "insert value" operation that increments all coordinate values after a given one, creating space for a newly inserted point. (I have heard the term "*list space*" for this. Should we just use "rank space"?)

**Stabbing. **So far, our data set consisted of points and the queries asked for points in a given rectangle. Conversely, one can consider a data set of rectangles; the query is a point and asks about the rectangles containing that point ("stabbed" by it). This problem is important, among others, in routing: we can have rules for packets coming from some range of IP addresses and going to some other range of IP addresses.

The notion of rank space, and all query combinations still make sense. For instance, *interval max stabbing* is the following problem: given a set of interval (in 1D) with priorities, return the interval of highest priority stabbed by a query point.

Note that the rectangles in the input can intersect! If we ask that the rectangles be disjoint, or more stringently, be a partition of the space, we obtain the *point location problem.*

**Rectangle-rectangle queries. **So far we looked at containment relations between rectangles and points. More generally, the data set can consist of rectangles, and the query can also be a rectangle. Then one can ask:

*intersection queries*: analyze the set of input rectangles that intersect the query rectangle.*containment queries*: analyze the set of rectangles that contain / are-contained-by the query.

Two important special cases arise when the rectangles degenerate to line segments:

*orthogonal segment intersection*: Given a set of horizontal segments, find the ones that intersect a vertical query segment.

*orthogonal ray shooting*: Given a set of horizontal segments, find the lowest one immediately above a query point. In other words, consider a vertical ray leaving from the point and find the first segment it intersects. (This is the min segment intersection query, where the priority of each horizontal segment is its *y* coordinate.)

**More complex geometry. **Of course, our ranges need not be orthogonal. One can consider:

- balls
- arbitrary lines
- half spaces
- simplices (e.g 2D triangles).

In non-orthogonal geometry, the concept of rank space disappears. However, most other combinations are possible. For instance, one could ask about the points in a query range; the ranges stabbed by a query point; the ranges intersecting a query range; the first rangeintersected by a ray; etc. We can ask existential, counting, or reporting questions, on ranges that can have weights or priorities.