+ All Categories
Home > Documents > Geometric Data Structures Computational Geometry, WS 2007/08 Lecture 13 Prof. Dr. Thomas Ottmann...

Geometric Data Structures Computational Geometry, WS 2007/08 Lecture 13 Prof. Dr. Thomas Ottmann...

Date post: 20-Dec-2015
Category:
View: 217 times
Download: 0 times
Share this document with a friend
Popular Tags:
23
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
Transcript
Page 1: Geometric Data Structures Computational Geometry, WS 2007/08 Lecture 13 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.

Geometric Data Structures

Computational Geometry, WS 2007/08

Lecture 13

Prof. Dr. Thomas Ottmann

Algorithmen & Datenstrukturen, Institut für InformatikFakultät für Angewandte WissenschaftenAlbert-Ludwigs-Universität Freiburg

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 2

Overview

• Motivation: Rectangle Intersection

• Segment trees

• Interval trees

• Priority search trees

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 3

- Sweep a horizontal Scan-Line from top to bottom.- Store the intersection points with the rectangles in a status structure L.

Rectangle Intersection

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 4

- 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

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 5

x y x x xy y y

a b a b a b a b

Reduction of the overlap-query

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 6

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

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 7

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.

AB C D

E F

Example

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 8

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

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 9

AB 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 pl & x in I(pl)) then report(pl, x); if (p has right child pr & x in I(pr)) then report(pr, 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

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 10

I

I

I

I

I

I

Dictionary for all intervals

Deletion of intervals

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 11

o- Lists

u- ListsS

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

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 12

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]

[5, 7], [6, 7]

[1, 2]

[1, 2]

1

2

3 5

6

4

7

{[1, 2], [1, 5], [3, 4], [5, 7], [6, 7] , [1, 7] }

Example

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 13

Procedure report (p :nodes, x : points)if x = p.key then report all intervals of the u/o – listselse if x < p.key then { report beginning of the u-list; report(pl, x) }

else (x > p.key) { report beginning of the o - list;report(pr, x) }

Stabbing queries can be answered in O(log n + k) time, where k is the number of reported intervals.

X < p.keyX

X > p.keyX

u - lists o - lists

Answering stabbing queries

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 14

A B

C

D

A

B

C

D

l rx y

Priority Search Trees

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 15

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

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 16

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

83, 8

32 4 5 6 71

2, 41

4, 53

6, 95 7

1, 22

5, 46

8, 34

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 17

83, 8

32 4 5 6 71

2, 41

4, 53

6, 95 7

1, 22

5, 46

8, 34

Priority Search Tree: Insertion

Insert (7, 1)

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 18

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)

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 19

83, 8

32 4 56, 9

6 71

2, 41

4, 53

5, 45 7

1, 22

8, 36

7, 14

Priority Search Tree: Deletion

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 20

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

83, 8

32 4 56, 9

6 71

2, 41

4, 53

5, 45 7

1, 22

8, 36

7, 14

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 21

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

Executable in O(log n + k) time.

Answering range queries

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 22

483, 8

32 4 156, 926 371

2, 41

4, 53

15, 415 37

1, 22

48, 326

37, 14

Full dynamic PST

No rigid skeleton, but growing or shrinking with the point set.

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

Computational Geometry, WS 2007/08Prof. Dr. Thomas Ottmann 23

px, py

a b

qx, qy

b a

1 2

3 1

2 3

Rotation preserves the x-order, but may destroy the y-order of points.

Balanced trees as skeletons of PSTs


Recommended