Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Range tree

From Wikipedia, the free encyclopedia
Range tree
Typetree
Invented1979
Invented byJon Louis Bentley
Time complexity inbig O notation
OperationAverageWorst case
SearchO(logdn+k){\displaystyle O(\log ^{d}n+k)}O(logdn+k){\displaystyle O(\log ^{d}n+k)}
Space complexity
SpaceO(nlogd1n){\displaystyle O(n\log ^{d-1}n)}O(nlogd1n){\displaystyle O(n\log ^{d-1}n)}

Incomputer science, arange tree is anordered treedata structure to hold a list of points. It allows all points within a given range to bereported efficiently, and is typically used in two or higher dimensions. Range trees were introduced byJon Louis Bentley in 1979.[1] Similar data structures were discovered independently by Lueker,[2] Lee and Wong,[3] and Willard.[4]The range tree is an alternative to thek-d tree. Compared tok-d trees, range trees offer faster query times of (inBig O notation)O(logdn+k){\displaystyle O(\log ^{d}n+k)} but worse storage ofO(nlogd1n){\displaystyle O(n\log ^{d-1}n)}, wheren is the number of points stored in the tree,d is the dimension of each point andk is the number of points reported by a given query.

In 1990,Bernard Chazelle improved this to query timeO(logd1n+k){\displaystyle O(\log ^{d-1}n+k)} and space complexityO(n(lognloglogn)d1){\displaystyle O\left(n\left({\frac {\log n}{\log \log n}}\right)^{d-1}\right)}.[5][6]

Data structure

[edit]
An example of a 1-dimensional range tree.
An example of a 1-dimensional range tree. Each node which is not a leaf stores the largest value of its left subtree.

A range tree on a set of 1-dimensional points is a balancedbinary search tree on those points. The points stored in the tree are stored in the leaves of the tree; each internal node stores the largest value of its left subtree.A range tree on a set of points ind-dimensions is arecursively defined multi-levelbinary search tree. Each level of the data structure is a binary search tree on one of thed-dimensions.The first level is a binary search tree on the first of thed-coordinates. Each vertexv of this tree contains an associated structure that is a (d−1)-dimensional range tree on the last (d−1)-coordinates of the points stored in the subtree ofv.

Operations

[edit]

Construction

[edit]

A 1-dimensional range tree on a set ofn points is a binary search tree, which can be constructed inO(nlogn){\displaystyle O(n\log n)} time. Range trees in higher dimensions are constructed recursively by constructing a balanced binary search tree on the first coordinate of the points, and then, for each vertexv in this tree, constructing a (d−1)-dimensional range tree on the points contained in the subtree ofv. Constructing a range tree this way would requireO(nlogdn){\displaystyle O(n\log ^{d}n)} time.

This construction time can be improved for 2-dimensional range trees toO(nlogn){\displaystyle O(n\log n)}.[7]LetS be a set ofn 2-dimensional points. IfS contains only one point, return a leaf containing that point. Otherwise, construct the associated structure ofS, a 1-dimensional range tree on they-coordinates of the points inS. Letxm be the medianx-coordinate of the points. LetSL be the set of points withx-coordinate less than or equal toxm and letSR be the set of points withx-coordinate greater thanxm. Recursively constructvL, a 2-dimensional range tree onSL, andvR, a 2-dimensional range tree onSR. Create a vertexv with left-childvL and right-childvR.If we sort the points by theiry-coordinates at the start of the algorithm, and maintain this ordering when splitting the points by theirx-coordinate, we can construct the associated structures of each subtree in linear time.This reduces the time to construct a 2-dimensional range tree toO(nlogn){\displaystyle O(n\log n)}, and also reduces the time to construct ad-dimensional range tree toO(nlogd1n){\displaystyle O(n\log ^{d-1}n)}.

Range queries

[edit]
A 1-dimensional range query.
A 1-dimensional range query [x1,x2]. Points stored in the subtrees shaded in gray will be reported. find(x1) and find(x2) will be reported if they are inside the query interval.

Arange query on a range tree reports the set of points that lie inside a given interval. To report the points that lie in the interval [x1,x2], we start by searching forx1 andx2. At some vertex in the tree, the search paths tox1 andx2 will diverge. Letvsplit be the last vertex that these two search paths have in common. For every vertexv in the search path fromvsplit tox1, if the value stored atv is greater thanx1, report every point in the right-subtree ofv. Ifv is a leaf, report the value stored atv if it is inside the query interval. Similarly, reporting all of the points stored in the left-subtrees of the vertices with values less thanx2 along the search path fromvsplit tox2, and report the leaf of this path if it lies within the query interval.

Since the range tree is a balanced binary tree, the search paths tox1 andx2 have lengthO(logn){\displaystyle O(\log n)}. Reporting all of the points stored in the subtree of a vertex can be done in linear time using anytree traversal algorithm. It follows that the time to perform a range query isO(logn+k){\displaystyle O(\log n+k)}, wherek is the number of points in the query interval.

Range queries ind-dimensions are similar. Instead of reporting all of the points stored in the subtrees of the search paths, perform a (d−1)-dimensional range query on the associated structure of each subtree. Eventually, a 1-dimensional range query will be performed and the correct points will be reported. Since ad-dimensional query consists ofO(logn){\displaystyle O(\log n)} (d−1)-dimensional range queries, it follows that the time required to perform ad-dimensional range query isO(logdn+k){\displaystyle O(\log ^{d}n+k)}, wherek is the number of points in the query interval. This can be reduced toO(logd1n+k){\displaystyle O(\log ^{d-1}n+k)} using a variant offractional cascading.[2][4][7]

See also

[edit]

References

[edit]
  1. ^Bentley, J. L. (1979)."Decomposable searching problems"(PDF).Information Processing Letters.8 (5):244–251.doi:10.1016/0020-0190(79)90117-0.Archived from the original on September 24, 2017.
  2. ^abLueker, G. S. (1978). "A data structure for orthogonal range queries".19th Annual Symposium on Foundations of Computer Science (sfcs 1978). pp. 28–21.doi:10.1109/SFCS.1978.1.S2CID 14970942.
  3. ^Lee, D. T.; Wong, C. K. (1980). "Quintary trees: A file structure for multidimensional database systems".ACM Transactions on Database Systems.5 (3): 339.doi:10.1145/320613.320618.S2CID 2547376.
  4. ^abWillard, Dan E.The super-b-tree algorithm (Technical report). Cambridge, MA: Aiken Computer Lab, Harvard University. TR-03-79.
  5. ^Chazelle, Bernard (1990)."Lower Bounds for Orthogonal Range Searching: I. The Reporting Case"(PDF).Journal of the ACM.37 (2):200–212.doi:10.1145/77600.77614.S2CID 8895683.
  6. ^Chazelle, Bernard (1990)."Lower Bounds for Orthogonal Range Searching: II. The Arithmetic Model"(PDF).Journal of the ACM.37:439–463.doi:10.1145/79147.79149.S2CID 15935619.
  7. ^abde Berg, Mark; Cheong, Otfried; van Kreveld, Marc; Overmars, Mark (2008).Computational Geometry.doi:10.1007/978-3-540-77974-2.ISBN 978-3-540-77973-5.

External links

[edit]
Search trees
(dynamic sets/associative arrays)
Heaps
Tries
Spatial data partitioning trees
Other trees
Retrieved from "https://en.wikipedia.org/w/index.php?title=Range_tree&oldid=1239516617"
Categories:

[8]ページ先頭

©2009-2025 Movatter.jp