Presentation is loading. Please wait.

Presentation is loading. Please wait.

Geometric Data Structures Computational Geometry, WS 2007/08 Lecture 13 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.

Similar presentations


Presentation on theme: "Geometric Data Structures Computational Geometry, WS 2007/08 Lecture 13 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik."— Presentation transcript:

1 Geometric Data Structures Computational Geometry, WS 2007/08 Lecture 13 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 2007/08 Prof. Dr. Thomas Ottmann2 Overview Motivation: Rectangle Intersection Segment trees Interval trees Priority search trees

3 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann3 - Sweep a horizontal Scan-Line from top to bottom. - Store the intersection points with the rectangles in a status structure L. Rectangle Intersection

4 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann4 - Insertion of an interval into L - deletion of an interval from L - For a given interval I : Determine all intervals from L, which overlap themselves with I L stores a set of intervals over a discrete and well-known universe of possible end-points. Operations on L

5 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann5 xyxxxyyy abababab Reduction of the overlap-query

6 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann6 Segment trees are a structure for storing sets of intervals, which support the following operations: - insertion of intervals - deletion of intervals - stabbing queries: For a given point A, report all intervals which contain A (which are stabbed by A) For the solution of the rectangle intersection problem semi-dynamic segment trees are sufficient. Segment Trees

7 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann7 An interval I is in the list of a vertex p if and only if p is the first node from the root, so that the interval of I(p) is contained in I. Insertion of an interval is possible in O(log n) steps. A B C D E F Example

8 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann8 I Each interval of I appears in at the most O(log n) interval lists. Construction of a segment tree with n intervals is possible in time O(n log n). Size of a Segment Tree

9 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann9 A B C D E F procedure report (p: node ; x: point): report all intervals of the list of p; if p is leaf then finish else { if (p has left child p l & x in I(p l )) then report(p l, x); if (p has right child p r & x in I(p r )) then report(p r, x); } Using the segment tree all intervals that contain a query point can be reported in time O(log n + k), where k is the number of reported intervals. Algorithm for answering stabbing queries

10 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann10 I I I I I I Dictionary for all intervals Deletion of intervals

11 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann11 o- Lists u- Lists S Skeleton (complete search tree of the interval boundaries) o-Lists sorted according to descending upper end points u-Lists sorted according to ascending lower end points Interval [ l,r ] is stored in the u-/ o-list of the node s forwards if and only if s of the knots of minimum depth is, so that s lies in [ l,r ]. Interval Trees

12 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann12 Insertion and deletion of intervals in an interval tree with skeleton of size O(n) and altogether O(n) intervals can be carried out in time O(log n). [1, 5], [1, 7], [3, 4] [1, 7], [1, 5], [3, 4] [5, 7], [6, 7] [1, 2] 1 2 35 6 4 7 {[1, 2], [1, 5], [3, 4], [5, 7], [6, 7], [1, 7] } Example

13 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann13 Procedure report (p :nodes, x : points) if x = p.key then report all intervals of the u/o – lists else if x p.key) { report beginning of the o - list;report(p r, x) } Stabbing queries can be answered in O(log n + k) time, where k is the number of reported intervals. X < p.key X X > p.key X u - listso - lists Answering stabbing queries

14 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann14 A B C D A B C D lr xy Priority Search Trees

15 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann15 Priority Search trees are a 1.5-dim structure for the storage of points, they support the following operations : Insertion of a point Deletion of a point South-grounded range queries Priority Search Trees

16 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann16 Priority search trees are - binary leaf search trees for the x-coordinates of the points. - min heaps for the y-coordinates of the points. M = { (1, 2), (2, 4), (3, 8), (4, 5), (5, 4), (6, 9), (8, 3) } Priority Search Trees 8 3, 8 3245671 2, 4 1 4, 5 3 6, 9 57 1, 2 2 5, 4 6 8, 3 4

17 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann17 8 3, 8 3245671 2, 4 1 4, 5 3 6, 9 57 1, 2 2 5, 4 6 8, 3 4 Priority Search Tree: Insertion Insert (7, 1)

18 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann18 Insertion Algorithm Insertion of a point p = (x, y) : Deposite p on the search path for x according to its y-value! I.e. if on the way down the tree, p meets a point q, with larger y-value, then deposit p there and and continue the procedure with q. Insertion of a point can be carried out in time O(log n). Observation: For any given set P of n points in the plane, there exists a uniquely defined PST storing P; it can be constructed in time O(n log n) and space O(n)

19 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann19 8 3, 8 3245 6, 9 671 2, 4 1 4, 5 3 5, 4 57 1, 2 2 8, 3 6 7, 1 4 Priority Search Tree: Deletion

20 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann20 Look for point p in the tree and remove it; Close the gaps (recursively) by pulling up the point, with smaller y-value. Deletion of a point is possible in time O(log n). Deletion 8 3, 8 3245 6, 9 671 2, 4 1 4, 5 3 5, 4 57 1, 2 2 8, 3 6 7, 1 4

21 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann21 South-grounded range queries (x, x´, y) : Search for x and x´. Report all points with y-value < y within the range between these borders. x y x´ Executable in O(log n + k) time. Answering range queries

22 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann22 48 3, 8 32415 6, 9 26371 2, 4 1 4, 5 3 15, 4 1537 1, 2 2 48, 3 26 37, 1 4 Full dynamic PST No rigid skeleton, but growing or shrinking with the point set.

23 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann23 p x, p y ab q x, q y b a 12 31 23 Rotation preserves the x-order, but may destroy the y-order of points. Balanced trees as skeletons of PSTs


Download ppt "Geometric Data Structures Computational Geometry, WS 2007/08 Lecture 13 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik."

Similar presentations


Ads by Google