Computational Geometry Lecture 14: Windowing queries Computational - - PowerPoint PPT Presentation

computational geometry
SMART_READER_LITE
LIVE PREVIEW

Computational Geometry Lecture 14: Windowing queries Computational - - PowerPoint PPT Presentation

Motivation Interval trees Priority search trees Windowing queries Computational Geometry Lecture 14: Windowing queries Computational Geometry Lecture 14: Windowing queries Motivation Interval trees Windowing queries Priority search trees


slide-1
SLIDE 1

Motivation Interval trees Priority search trees

Windowing queries

Computational Geometry

Lecture 14: Windowing queries

Computational Geometry Lecture 14: Windowing queries

slide-2
SLIDE 2

Motivation Interval trees Priority search trees Windowing queries

Windowing

Zoom in; re-center and zoom in; select by outlining

Computational Geometry Lecture 14: Windowing queries

slide-3
SLIDE 3

Motivation Interval trees Priority search trees Windowing queries

Windowing

Computational Geometry Lecture 14: Windowing queries

slide-4
SLIDE 4

Motivation Interval trees Priority search trees Windowing queries

Windowing

Given a set of n axis-parallel line segments, preprocess them into a data structure so that the ones that intersect a query rectangle can be reported efficiently

Computational Geometry Lecture 14: Windowing queries

slide-5
SLIDE 5

Motivation Interval trees Priority search trees Windowing queries

Windowing

How can a rectangle and an axis-parallel line segment intersect?

Computational Geometry Lecture 14: Windowing queries

slide-6
SLIDE 6

Motivation Interval trees Priority search trees Windowing queries

Windowing

Essentially two types: Segments whose endpoint lies in the rectangle (or both endpoints) Segments with both endpoints

  • utside the rectangle

Segments of the latter type always intersect the boundary of the rectangle (even the left and/or bottom side)

Computational Geometry Lecture 14: Windowing queries

slide-7
SLIDE 7

Motivation Interval trees Priority search trees Windowing queries

Windowing

Instead of storing axis-parallel segments and searching with a rectangle, we will: store the segment endpoints and query with the rectangle store the segments and query with the left side and the bottom side of the rectangle Note that the query problem is at least as hard as rectangular range searching in point sets

Computational Geometry Lecture 14: Windowing queries

slide-8
SLIDE 8

Motivation Interval trees Priority search trees Windowing queries

Windowing

Instead of storing axis-parallel segments and searching with a rectangle, we will: store the segment endpoints and query with the rectangle store the segments and query with the left side and the bottom side of the rectangle Question: How often might we report the same segment?

Computational Geometry Lecture 14: Windowing queries

slide-9
SLIDE 9

Motivation Interval trees Priority search trees Windowing queries

Avoiding reporting the same segment several times

Use one representation of each segment, and store a mark bit with it that is initially false When we think we should report a segment, we first check its mark bit:

  • if false, then report it and set the mark bit to true
  • otherwise, don’t do anything

After a query, we need to reset all mark bits to false, for the next query (how?)

Computational Geometry Lecture 14: Windowing queries

slide-10
SLIDE 10

Motivation Interval trees Priority search trees Windowing queries

Windowing

Instead of storing axis-parallel segments and searching with a rectangle, we will: store the segment endpoints and query with the rectangle use range tree (from Chapter 5) store the segments and query with the left side and the bottom side of the rectangle need to develop data structure

Computational Geometry Lecture 14: Windowing queries

slide-11
SLIDE 11

Motivation Interval trees Priority search trees Windowing queries

Windowing

Current problem of our interest: Given a set of horizontal (vertical) line segments, preprocess them into a data structure so that the ones intersecting a vertical (horizontal) query segment can be reported efficiently Question: Do we also need to store vertical segments for querying with vertical segments?

Computational Geometry Lecture 14: Windowing queries

slide-12
SLIDE 12

Motivation Interval trees Priority search trees Windowing queries

Windowing

Simpler query problem: What if the vertical query segment is a full line? Then the problem is essentially 1-dimensional

Computational Geometry Lecture 14: Windowing queries

slide-13
SLIDE 13

Motivation Interval trees Priority search trees Definition Querying Construction

Interval querying

Given a set I of n intervals on the real line, preprocess them into a data structure so that the ones containing a query point (value) can be reported efficiently

Computational Geometry Lecture 14: Windowing queries

slide-14
SLIDE 14

Motivation Interval trees Priority search trees Definition Querying Construction

Splitting a set of intervals

The median x of the 2n endpoints partitions the intervals into three subsets: Intervals Ileft fully left of x Intervals Imid that contain (intersect) x Intervals Iright fully right of x

x

Computational Geometry Lecture 14: Windowing queries

slide-15
SLIDE 15

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: recursive definition

The interval tree for I has a root node ν that contains x and the intervals Ileft are stored in the left subtree of ν the intervals Imid are stored with ν the intervals Iright are stored in the right subtree of ν The left and right subtrees are proper interval trees for Ileft and Iright How many intervals can be in Imid? How should we store Imid?

Computational Geometry Lecture 14: Windowing queries

slide-16
SLIDE 16

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: left and right lists

How is Imid stored?

x

Observe: If the query point is left of x, then only the left endpoint determines if an interval is an answer Symmetrically: If the query point is right of x, then only the right endpoint determines if an interval is an answer

Computational Geometry Lecture 14: Windowing queries

slide-17
SLIDE 17

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: left and right lists

x

Make a list Lleft using the left-to-right order of the left endpoints of Imid Make a list Lright using the right-to-left order of the right endpoints of Imid Store both lists as associated structures with ν

Computational Geometry Lecture 14: Windowing queries

slide-18
SLIDE 18

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-19
SLIDE 19

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: storage

The main tree has O(n) nodes The total length of all lists is 2n because each interval is stored exactly twice: in Lleft and Lright and only at one node Consequently, the interval tree uses O(n) storage

Computational Geometry Lecture 14: Windowing queries

slide-20
SLIDE 20

Motivation Interval trees Priority search trees Definition Querying Construction

Interval querying

Algorithm QueryIntervalTree(ν,qx) 1. if ν is not a leaf 2. then if qx < xmid(ν) 3. then Traverse list Lleft(ν), starting at the interval with the leftmost endpoint, reporting all the intervals that contain qx. Stop as soon as an interval does not contain qx. 4. QueryIntervalTree(lc(ν),qx) 5. else Traverse list Lright(ν), starting at the interval with the rightmost endpoint, reporting all the intervals that contain qx. Stop as soon as an interval does not contain qx. 6. QueryIntervalTree(rc(ν),qx)

Computational Geometry Lecture 14: Windowing queries

slide-21
SLIDE 21

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-22
SLIDE 22

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-23
SLIDE 23

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-24
SLIDE 24

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-25
SLIDE 25

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-26
SLIDE 26

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-27
SLIDE 27

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-28
SLIDE 28

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-29
SLIDE 29

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-30
SLIDE 30

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-31
SLIDE 31

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Lleft Lright

Computational Geometry Lecture 14: Windowing queries

slide-32
SLIDE 32

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query time

The query follows only one path in the tree, and that path has length O(logn) The query traverses O(logn) lists. Traversing a list with k′ answers takes O(1+k′) time The total time for list traversal is therefore O(log+k), with the total number of answers reported (no answer is found more than once) The query time is O(logn)+O(logn+k) = O(logn+k)

Computational Geometry Lecture 14: Windowing queries

slide-33
SLIDE 33

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: query example

Algorithm ConstructIntervalTree(I)

  • Input. A set I of intervals on the real line
  • Output. The root of an interval tree for I

1. if I = / 2. then return an empty leaf 3. else Create a node ν. Compute xmid, the median of the set of interval endpoints, and store xmid with ν 4. Compute Imid and construct two sorted lists for Imid: a list Lleft(ν) sorted on left endpoint and a list Lright(ν) sorted on right endpoint. Store these two lists at ν 5. lc(ν) ← ConstructIntervalTree(Ileft) 6. rc(ν) ← ConstructIntervalTree(Iright) 7. return ν

Computational Geometry Lecture 14: Windowing queries

slide-34
SLIDE 34

Motivation Interval trees Priority search trees Definition Querying Construction

Interval tree: result

Theorem: An interval tree for a set I of n intervals uses O(n) storage and can be built in O(nlogn) time. All intervals that contain a query point can be reported in O(logn+k) time, where k is the number of reported intervals.

Computational Geometry Lecture 14: Windowing queries

slide-35
SLIDE 35

Motivation Interval trees Priority search trees

Back to the plane

Computational Geometry Lecture 14: Windowing queries

slide-36
SLIDE 36

Motivation Interval trees Priority search trees

Back to the plane

Suppose we use an interval tree on the x-intervals of the horizontal line segments? Then the lists Lleft and Lright are not suitable anymore to solve the query problem for the segments corresponding to Imid

Computational Geometry Lecture 14: Windowing queries

slide-37
SLIDE 37

Motivation Interval trees Priority search trees

Back to the plane

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

Computational Geometry Lecture 14: Windowing queries

slide-38
SLIDE 38

Motivation Interval trees Priority search trees

Back to the plane

s1 s2 s3 s4 s5 s7 s8 s9 s10 s11 s12 s6 s7, s5, s6 s5, s6, s7 s8 s8 s9, s10 s9, s10 s11, s12 s12, s11 s4, s3, s2 s4, s3, s2 s1 s1

q

Computational Geometry Lecture 14: Windowing queries

slide-39
SLIDE 39

Motivation Interval trees Priority search trees

Back to the plane

s5 s7 s6 s7, s5, s6 s5, s6, s7

q

Computational Geometry Lecture 14: Windowing queries

slide-40
SLIDE 40

Motivation Interval trees Priority search trees

Back to the plane

s7 s6 s7, s5, s6 s5, s6, s7

q

s5

Computational Geometry Lecture 14: Windowing queries

slide-41
SLIDE 41

Motivation Interval trees Priority search trees

Back to the plane

s7 s6 { s2, s5, s6, s7, s9, s22 }

q

s5 s9 s2 s22 { s2, s5, s6, s7, s9, s22 }

Computational Geometry Lecture 14: Windowing queries

slide-42
SLIDE 42

Motivation Interval trees Priority search trees

Back to the plane

s7 s6 { s2, s5, s6, s7, s9, s22 }

q

s5 s9 s2 s22 { s2, s5, s6, s7, s9, s22 }

Computational Geometry Lecture 14: Windowing queries

slide-43
SLIDE 43

Motivation Interval trees Priority search trees

Back to the plane

s7 s6 { s2, s5, s6, s7, s9, s22 }

q

s5 s9 s2 s22 { s2, s5, s6, s7, s9, s22 }

q

Computational Geometry Lecture 14: Windowing queries

slide-44
SLIDE 44

Motivation Interval trees Priority search trees

Segment intersection queries

We can use a range tree (chapter 5) as the associated structure; we only need one that stores all of the endpoints, to replace Lleft and Lright Instead of traversing Lleft or Lright, we perform a query with the region left or right, respectively, of q

Computational Geometry Lecture 14: Windowing queries

slide-45
SLIDE 45

Motivation Interval trees Priority search trees

Segment intersection queries

s7 s6

q

s5 s9 s2 s22

q

{ s2, s5, s6, s7, s9, s22 } all endpoints of

Computational Geometry Lecture 14: Windowing queries

slide-46
SLIDE 46

Motivation Interval trees Priority search trees

Segment intersection queries

In total, there are O(n) range trees that together store 2n points, so the total storage needed by all associated structures is O(nlogn) A query with a vertical segment leads to O(logn) range queries If fractional cascading is used in the associated structures, the

  • verall query time is O(log2 n+k)

Question: How about the construction time?

Computational Geometry Lecture 14: Windowing queries

slide-47
SLIDE 47

Motivation Interval trees Priority search trees Definition Querying

3- and 4-sided ranges

Considering the associated structure, we only need 3-sided range queries, whereas the range tree provides 4-sided range queries Can the 3-sided range query problem be solved more efficiently than the 4-sided (rectangular) range query problem?

Computational Geometry Lecture 14: Windowing queries

slide-48
SLIDE 48

Motivation Interval trees Priority search trees Definition Querying

Scheme of structure

s7 s6

q

s5 s9 s2 s22

q

{ s2, s5, s6, s7, s9, s22 } all right endpoints of all left endpoints of { s2, s5, s6, s7, s9, s22 }

Computational Geometry Lecture 14: Windowing queries

slide-49
SLIDE 49

Motivation Interval trees Priority search trees Definition Querying

Heap and search tree

A priority search tree is like a heap on x-coordinate and binary search tree on y-coordinate at the same time Recall the heap:

6 1 2 3 7 4 8 11 5 13 10 14 12 9

Computational Geometry Lecture 14: Windowing queries

slide-50
SLIDE 50

Motivation Interval trees Priority search trees Definition Querying

Heap and search tree

A priority search tree is like a heap on x-coordinate and binary search tree on y-coordinate at the same time Recall the heap:

6 1 2 3 7 4 8 11 5 13 10 14 12 9

Report all values ≤ 4

Computational Geometry Lecture 14: Windowing queries

slide-51
SLIDE 51

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

If P = / 0, then a priority search tree is an empty leaf Otherwise, let pmin be the leftmost point in P, and let ymid be the median y-coordinate of P\{pmin} The priority search tree has a node ν that stores pmin and ymid, and a left subtree and right subtree for the points in P\{pmin} with y-coordinate ≤ ymid and > ymid

pmin ymid

pmin ymid

Computational Geometry Lecture 14: Windowing queries

slide-52
SLIDE 52

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p1 p8 p12 p14 p13 p10 p11 p9 p2 p3 p4 p7 p5 p6

Computational Geometry Lecture 14: Windowing queries

slide-53
SLIDE 53

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p1 p8 p12 p14 p13 p10 p11 p9 p2 p3 p4 p7 p5 p6

Computational Geometry Lecture 14: Windowing queries

slide-54
SLIDE 54

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p1 p8 p12 p14 p13 p10 p11 p9 p2 p3 p4 p7 p5 p6

Computational Geometry Lecture 14: Windowing queries

slide-55
SLIDE 55

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p1 p8 p12 p14 p13 p10 p11 p9 p2 p3 p4 p7 p5 p6

Computational Geometry Lecture 14: Windowing queries

slide-56
SLIDE 56

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p1 p8 p12 p14 p13 p10 p11 p9 p2 p3 p4 p7 p5 p6

Computational Geometry Lecture 14: Windowing queries

slide-57
SLIDE 57

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p1 p8 p12 p14 p13 p10 p11 p9 p2 p3 p4 p7 p5 p6

Computational Geometry Lecture 14: Windowing queries

slide-58
SLIDE 58

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p1 p8 p12 p14 p13 p10 p11 p9 p2 p3 p4 p7 p5 p6

Computational Geometry Lecture 14: Windowing queries

slide-59
SLIDE 59

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p1 p8 p12 p14 p13 p10 p11 p9 p2 p3 p4 p7 p5 p6

Computational Geometry Lecture 14: Windowing queries

slide-60
SLIDE 60

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p1 p8 p12 p14 p13 p10 p11 p9 p2 p3 p4 p7 p5 p6

Computational Geometry Lecture 14: Windowing queries

slide-61
SLIDE 61

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p1 p8 p12 p14 p13 p10 p11 p9 p2 p3 p4 p7 p5 p6

Computational Geometry Lecture 14: Windowing queries

slide-62
SLIDE 62

Motivation Interval trees Priority search trees Definition Querying

Priority search tree

p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p1 p8 p12 p14 p13 p10 p11 p9 p2 p3 p4 p7 p5 p6

Computational Geometry Lecture 14: Windowing queries

slide-63
SLIDE 63

Motivation Interval trees Priority search trees Definition Querying

Query algorithm

Algorithm QueryPrioSearchTree(T,(−∞ : qx]×[qy : q′

y])

1. Search with qy and q′

y in T

2. Let νsplit be the node where the two search paths split 3. for each node ν on the search path of qy or q′

y

4. do if p(ν) ∈ (−∞ : qx]×[qy : q′

y] then report p(ν)

5. for each node ν on the path of qy in the left subtree of νsplit 6. do if the search path goes left at ν 7. then ReportInSubtree(rc(ν),qx) 8. for each node ν on the path of q′

y in the right subtree of νsplit

9. do if the search path goes right at ν 10. then ReportInSubtree(lc(ν),qx)

Computational Geometry Lecture 14: Windowing queries

slide-64
SLIDE 64

Motivation Interval trees Priority search trees Definition Querying

Structure of the query

Computational Geometry Lecture 14: Windowing queries

slide-65
SLIDE 65

Motivation Interval trees Priority search trees Definition Querying

Structure of the query

Computational Geometry Lecture 14: Windowing queries

slide-66
SLIDE 66

Motivation Interval trees Priority search trees Definition Querying

Query algorithm

ReportInSubtree(ν,qx)

  • Input. The root ν of a subtree of a priority search tree and a

value qx

  • Output. All points in the subtree with x-coordinate at most qx

1. if ν is not a leaf and (p(ν))x ≤ qx 2. then Report p(ν) 3. ReportInSubtree(lc(ν),qx) 4. ReportInSubtree(rc(ν),qx) This subroutine takes O(1+k) time, for k reported answers

Computational Geometry Lecture 14: Windowing queries

slide-67
SLIDE 67

Motivation Interval trees Priority search trees Definition Querying

Query algorithm

The search paths to y and y′ have O(logn) nodes. At each node O(1) time is spent No nodes outside the search paths are ever visited Subtrees of nodes between the search paths are queried like a heap, and we spend O(1+k′) time on each one The total query time is O(logn+k), if k points are reported

Computational Geometry Lecture 14: Windowing queries

slide-68
SLIDE 68

Motivation Interval trees Priority search trees Definition Querying

Priority search tree: result

Theorem: A priority search tree for a set P of n points uses O(n) storage and can be built in O(nlogn) time. All points that lie in a 3-sided query range can be reported in O(logn+k) time, where k is the number of reported points

Computational Geometry Lecture 14: Windowing queries

slide-69
SLIDE 69

Motivation Interval trees Priority search trees

Scheme of structure

s7 s6

q

s5 s9 s2 s22

q

{ s2, s5, s6, s7, s9, s22 } all right endpoints of all left endpoints of { s2, s5, s6, s7, s9, s22 }

Computational Geometry Lecture 14: Windowing queries

slide-70
SLIDE 70

Motivation Interval trees Priority search trees

Storage of the structure

Question: What are the storage requirements of the structure for querying with a vertical segment in a set of horizontal segments?

Computational Geometry Lecture 14: Windowing queries

slide-71
SLIDE 71

Motivation Interval trees Priority search trees

Query time of the structure

Question: What is the query time of the structure for querying with a vertical segment in a set of horizontal segments?

Computational Geometry Lecture 14: Windowing queries

slide-72
SLIDE 72

Motivation Interval trees Priority search trees

Result

Theorem: A set of n horizontal line segments can be stored in a data structure with size O(n) such that intersection queries with a vertical line segment can be performed in O(log2 n+k) time, where k is the number of segments reported

Computational Geometry Lecture 14: Windowing queries

slide-73
SLIDE 73

Motivation Interval trees Priority search trees

Result

Recall that the windowing problem is solved with a combination of a range tree and the structure just described Theorem: A set of n axis-parallel line segments can be stored in a data structure with size O(nlogn) such that windowing queries can be performed in O(log2 n+k) time, where k is the number of segments reported

Computational Geometry Lecture 14: Windowing queries

slide-74
SLIDE 74

Motivation Interval trees Priority search trees

Interesting

Just to confuse you (even more).... A priority search tree can be used to solve the interval stabbing problem (store 1-dim intervals, query with a point) (!?)

Computational Geometry Lecture 14: Windowing queries

slide-75
SLIDE 75

Motivation Interval trees Priority search trees

Transformation

Let I be a set of n intervals. Transform each 1-dim interval [a,b] to the point (a,b) in the plane A query with value q is transformed to the 2-sided range (−∞,q]×[q,+∞) Correctness: q ∈ [a,b] if and only if (a,b) ∈ (−∞,q]×[q,+∞)

Computational Geometry Lecture 14: Windowing queries

slide-76
SLIDE 76

Motivation Interval trees Priority search trees

Transformation

Computational Geometry Lecture 14: Windowing queries

slide-77
SLIDE 77

Motivation Interval trees Priority search trees

Example query

(8,8) 8

Computational Geometry Lecture 14: Windowing queries

slide-78
SLIDE 78

Motivation Interval trees Priority search trees

Example query

(26,26) 26

Computational Geometry Lecture 14: Windowing queries

slide-79
SLIDE 79

Motivation Interval trees Priority search trees

Food for thought

Question: Can an interval tree be used (after some transformation) to answer 3-sided range queries? Question: Can the priority search tree be used as the main tree for the structure that queries with a vertical line segment in horizontal line segments? Question: Can the priority search tree or the interval tree be augmented for interval stabbing counting queries?

Computational Geometry Lecture 14: Windowing queries