segment tree
By Zohre Akbari January2014
1
segment tree By Zohre Akbari January2014 2 Arbitrarily oriented - - PowerPoint PPT Presentation
1 segment tree By Zohre Akbari January2014 2 Arbitrarily oriented segments Two cases of intersection: An endpoint lies inside the query window; solve with range trees The segment intersects the window boundary; solve how? 3
1
2
its bounding box.
bounding box sides.
A simple solution:
Arbitrarily oriented segm ents
3
its bounding box.
bounding box sides.
intersect W whereas none of the segments do.
A simple solution: In the worst case:
Arbitrarily oriented segm ents
4
π§].
5
6
line, preprocess them into a data structure so that the ones containing a query point (value) can be reported efficiently
7
regions where the answer to a query is the same.
8
regions where the answer to a query is the same.
real line. Let π1, π2, . . . ,ππbe the list of distinct interval endpoints, sorted from left to right; m β€2n
9
regions where the answer to a query is the same.
real line. . Let π1, π2, . . . ,ππ be the list of distinct interval endpoints, sorted from left to right; m β€2n
called the elementary intervals.
10
has a leaf for every elementary interval.
corresponding to a leaf π by Int(π).
Int(π) are stored at the leaf π
interval that is the union of the elementary intervals of all leaves below it
11
12
Query time
We can report the k intervals containing ππ¦ in O(log n + k) time.
13
π with v iff
Int(v ) β ππ but Int(p a rent(v )) β ππ .
14
π
15
16
17
Lem m a 10 .10
Proof.
18
19
20
21
22
23
24
25
26
Theorem 10 .12
27
π§].
28
29
30
31
32
33
34
35
36
37
38
Theorem 10 .13
39
Corollary 10 .14
40