Presentation is loading. Please wait.

Presentation is loading. Please wait.

Orthogonal Range Searching Computational Geometry, WS 2006/07 Lecture 13 - Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für.

Similar presentations


Presentation on theme: "Orthogonal Range Searching Computational Geometry, WS 2006/07 Lecture 13 - Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für."— Presentation transcript:

1 Orthogonal Range Searching Computational Geometry, WS 2006/07 Lecture 13 - Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften Albert-Ludwigs-Universität Freiburg

2 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann2 Orthogonal Range Searching 1.Linear Range Search : 1-dim Range Trees 2.2-dimensional Range Search : kd-trees 3.2-dimensional Range Search : 2-dim Range Trees 4.Range Search in Higher Dimensions

3 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann3 Range search Salary Children Age Input: Set of data points in d-space, orthogonal (iso-oriented) query range R Output: All points contained in R

4 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann4 Binary search tree (1-dimensional)

5 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann5 Binary leaf search tree

6 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann6 Range search

7 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann7 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.

8 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann8 Example – Binary Search Tree 49 23 80 1037 193 3101923 30 37 49 62 5970 59627080 89 95 97 Split node Query range: [22, 77]

9 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann9 Algorithm 1-d-range-search 1DRangeQuery (T, [x, x´]) v split = FindSplitNode (T, x, x´) if ( leaf (v split ) && v split in R=[x, x´]) then write v split ; return; v = left-child(v split ); 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(v split )... rchild(v) s v p xx´

10 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann10 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), since number of internal nodes is O(k)  O((log n)+k) total time.

11 Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann11 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.


Download ppt "Orthogonal Range Searching Computational Geometry, WS 2006/07 Lecture 13 - Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für."

Similar presentations


Ads by Google