Range searching explained

In computer science, the range searching problem consists of processing a set S of objects, in order to determine which objects from S intersect with a query object, called the range. For example, if S is a set of points corresponding to the coordinates of several cities, find the subset of cities within a given range of latitudes and longitudes.

The range searching problem and the data structures that solve it are a fundamental topic of computational geometry. Applications of the problem arise in areas such as geographical information systems (GIS), computer-aided design (CAD) and databases.

Variations

There are several variations of the problem, and different data structures may be necessary for different variations. In order to obtain an efficient solution, several aspects of the problem need to be specified:

Data structures

Orthogonal range searching

In orthogonal range searching, the set S consists of

n

points in

d

dimensions, and the query consists of intervals in each of those dimensions. Thus, the query consists of a multi-dimensional axis-aligned rectangle. With an output size of

k

, Jon Bentley used a k-d tree to achieve (in Big O notation)

O(n)

space and
1-
1
d
O(n

+k)

query time.[1] Bentley also proposed using range trees, which improved query time to

O(logdn+k)

but increased space to

O(nlogdn)

.[2] Dan Willard used downpointers, a special case of fractional cascading to reduce the query time further to

O(logdn+k)

. [3]

While the above results were achieved in the pointer machine model, further improvements have been made in the word RAM model of computation in low dimensions (2D, 3D, 4D). Bernard Chazelle used compress range trees to achieve

O(logn)

query time and

O(n)

space for range counting.[4] Joseph JaJa and others later improved this query time to

O\left(\dfrac{logn}{loglogn}\right)

for range counting, which matches a lower bound and is thus asymptotically optimal.[5]

As of 2015, the best results (in low dimensions (2D, 3D, 4D)) for range reporting found by Timothy M. Chan, Kasper Larsen, and Mihai Pătrașcu, also using compressed range trees in the word RAM model of computation, are one of the following:[6]

O(n)

space,

O(log\epsilonn+klog\epsilonn)

query time

O(nloglogn)

space,

O(loglogn+kloglogn)

query time

O(nlog\epsilonn)

space,

O(loglogn+k)

query time

In the orthogonal case, if one of the bounds is infinity, the query is called three-sided. If two of the bounds are infinity, the query is two-sided, and if none of the bounds are infinity, then the query is four-sided.

Dynamic range searching

While in static range searching the set S is known in advance, dynamic range searching, insertions and deletions of points are allowed. In the incremental version of the problem, only insertions are allowed, whereas the decremental version only allows deletions. For the orthogonal case, Kurt Mehlhorn and Stefan Näher created a data structure for dynamic range searching which uses dynamic fractional cascading to achieve

O(nlogn)

space and

O(lognloglogn+k)

query time.[7] Both incremental and decremental versions of the problem can be solved with

O(logn+k)

query time, but it is unknown whether general dynamic range searching can be done with that query time.

Colored range searching

The problem of colored range counting considers the case where points have categorical attributes. If the categories are considered as colors of points in geometric space, then a query is for how many colors appear in a particular range. Prosenjit Gupta and others described a data structure in 1995 which solved 2D orthogonal colored range counting in

O(n2log2n)

space and

O(log2n)

query time.[8]

Applications

In addition to being considered in computational geometry, range searching, and orthogonal range searching in particular, has applications for range queries in databases. Colored range searching is also used for and motivated by searching through categorical data. For example, determining the rows in a database of bank accounts which represent people whose age is between 25 and 40 and who have between $10000 and $20000 might be an orthogonal range reporting problem where age and money are two dimensions.

See also

Further reading

Notes and References

  1. Bentley. Jon. Jon Bentley (computer scientist). 1975. Multidimensional binary search trees used for associative searching . Communications of the ACM. 18. 9. 509–517 . 10.1145/361002.361007. 13091446. free.
  2. Bentley. Jon. Jon Bentley (computer scientist). 1980. Multidimensional divide-and-conquer . Communications of the ACM. 23. 4. 214–229 . 10.1145/358841.358850. 3997186. free.
  3. Willard. Dan. Dan Willard. 1985. New data structures for orthogonal range queries . SIAM Journal on Computing. 14. 1. 232–253 . 10.1137/0214019.
  4. Chazelle. Bernard. Bernard Chazelle. 1988. A functional approach to data structures and its use in multidimensional searching . SIAM Journal on Computing. 17. 3. 427–462 . 10.1137/0217026. 10.1.1.133.9153.
  5. JaJa. Joseph. Mortensen. Christian. Shi. Qingmin. 2005. Space-efficient and fast algorithms for multidimensional dominance reporting and counting . International Symposium on Algorithms and Computation. 558–568.
  6. Chan. Timothy. Timothy M. Chan. Larsen. Kasper. Pătrașcu. Mihai. Mihai Pătrașcu (computer scientist). 2011. Orthogonal range searching on the RAM, revisited . Symposium on Computational Geometry. 1–10. 1103.5510.
  7. Mehlhorn. Kurt. Kurt Mehlhorn. Näher. Stefan. 1990. Dynamic fractional cascading . Algorithmica. 5. 2. 215–241. 10.1007/BF01840386. 7721690.
  8. Gupta. Prosenjit. Janardan. Ravi. Smid. Michiel. 1995. Further results on generalized intersection searching problems: Counting, reporting, and dynamization . Journal of Algorithms. 19. 2. 282–317 . 10.1006/jagm.1995.1038. 11858/00-001M-0000-0014-B721-F. free.