110 likes | 287 Views
Orthogonal Range Searching. Linear Range Search : 1-dim Range Trees 2-dimensional Range Search : kd-trees 2-dimensional Range Search : 2-dim Range Trees Range Search in Higher Dimensions. Range search. Salary. Children. Age. Input: Set of data points in d-space,
E N D
Orthogonal Range Searching • Linear Range Search : 1-dim Range Trees • 2-dimensional Range Search : kd-trees • 2-dimensional Range Search : 2-dim Range Trees • Range Search in Higher Dimensions
Range search Salary Children Age Input: Setof data points in d-space, orthogonal (iso-oriented) query range R Output: All points contained in R
1-Dimensional range query Finding the split node for query range [x, x´] FindSplitNode (T, x, x´) v = root (T) while not leaf(v) && (x´ v.x || x > v.x) if (x´ v.x) then v = left(v) else v = right(v) return v Running time :O(log n) Note :Only O(log n) subtrees fall into the query range.
Example – Binary Search Tree Query range: [22, 77] Split node 49 80 23 89 10 37 62 95 59 70 89 30 49 3 19 95 97 3 10 19 23 30 37 59 62 70 80
s v rchild(v) p x x´ Algorithm 1-d-range-search 1DRangeQuery (T, [x, x´]) vsplit = FindSplitNode (T, x, x´) if ( leaf (vsplit) && vsplit in R=[x, x´]) then write vsplit; return; v = left-child(vsplit); while(not leaf (v)) if (x v.x ) then write Subtree (right-child(v)); v= left-child(v); else v = right-child(v) if (v in R) write v ; v = right-child(vsplit) ...
Theorem A 1-dim range query in a set of n points can be answered in time O(log n + k) using a 1-d-range tree, where k is the number of reported points which fall into the given range. Proof : FindSplitNode: O(log n) Leaf search: O(log n) The number of green nodes is O(k), sincenumber of internal nodes isO(k) O((log n)+k) total time.
Summary Let P be a set of n points in 1-dimensional space. The set P can be stored in a balanced binary search tree, which uses O(n) storage and has O(n log n) construction time, such that the points in a query range can be reported in time O(k + log n) , where k is the number of reported points.