1
1
CG Lecture 4 CG Lecture 4
Orthogonal range search
- 1. Problem definition and motivation
- 2. Space decomposition: techniques and trade-offs
- 3. Space decomposition schemes:
- Grids: uniform, non-hierarchical decomposition
- Quad trees: uniform, hierarchical decomposition
- Range trees and kd-trees: non-uniform, hierarchical
- 4. Higher dimensions, variations on the theme
2
Orthogonal range searching Orthogonal range searching
Problem: Given a set of n points in ℜd, preprocess them such that reporting or counting the k points inside a d- dimensional axis-parallel box (range) will be efficient. Sample application: Report all cities within 20 KM radius of Tel Aviv.
X Y
3
Space decomposition techniques Space decomposition techniques
- Different schemes for different types of data, with
various trade-offs
- Types of space decomposition:
- Grids: uniform, non-hierarchical decomposition
- Quad trees: uniform, hierarchical decomposition
- Range trees and kd-trees: non-uniform, hierarchical
- Key efficiency parameters:
- Preprocessing time:
f(n) Ω(n)
- Preprocessing storage
f(n) Ω(n)
- Average query time
f(n,k)
- Worst-case query time
f(n,k)
- Dynamical update (insertions/deletions) f(n)
4
Grids: uniform, non Grids: uniform, non-
- hierarchical
hierarchical
Method:
- Store points in a uniform array
[1:n]×[1:n]
- Query is answered by reporting
points in subarray [i:j] ×[k:l] Complexity:
- Preprocessing in O(n) time and
O(n2) storage.
- Query time O(k).
- Update in O(1) when points on
grid. Alternatives:
- List, sparse matrix, hashing
5
Quad trees: uniform, hierarchical Quad trees: uniform, hierarchical
Method:
- Recursively partition the space
into four quadrants until leaf quadrants contain a single point
- r no point.
- Query is answered by recursively
intersecting the query rectangle R with the quadrants and reporting the results according to the intersection. Complexity: depends on the nature
- f the data set, not just the
number of points!
6
Quad trees: construction Quad trees: construction
Method:
- Start with smallest rectangle
containing all points.
- Recusively classify point set into four
quadrants.
- Stop when quadrant has one or no
points. The height h of the tree is related to the size of the initial rectangle s and the smallest distance c between two points: h = log (s/c) + 3/2. A quad tree with n points and height h has O(h+1)n nodes and can be constructed in O(h+1)n time.
s/2 s/2i
i