fall 20051 orthogonal range search deberg et. al (chap.5)
TRANSCRIPT
![Page 1: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/1.jpg)
Fall 2005 1
Orthogonal Range Search
deBerg et. al (Chap.5)
![Page 2: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/2.jpg)
Fall 2005 2
1D Range SearchData stored in balanced binary search tree T Input: range tree T and range [x,x’]Output: all points in the range
![Page 3: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/3.jpg)
Fall 2005 3
Idea
Find split nodeFrom split node, find path to , the node x; report all right subtree along the pathFrom split node, find path to ’, the node x’; report all left subtree along the pathCheck and ’
x x’
split-node
![Page 4: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/4.jpg)
Fall 2005 4
Performance
T: O(n) storage, built in O(nlogn)Query: Worst case: (n) … sounds bad Refined analysis (output-sensitive)
Output k: ReportSubTree O(k) Traverse tree down to or ’: O(logn) Total: O(logn + k)
![Page 5: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/5.jpg)
Fall 2005 5
2D Kd-tree for 2D range search
Kd-tree: special case of BSPInput: [x,x’][y,y’]Output: all points in range
![Page 6: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/6.jpg)
Fall 2005 6
Build kd-tree
Break at median n/2 nodesLeft (and bottom) child stores the splitting line
)log()(
2/2)()(
nnOnT
nTnOnT
![Page 7: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/7.jpg)
Fall 2005 7
Step-by-Step (left subtree)
5
8
10
9
6
7
2
3
4
1
1,2,3,4,5 6,7,8,9,10
![Page 8: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/8.jpg)
Fall 2005 8
5
8
10
9
6
7
2
3
4
1
6,7,8,9,10
1,2,3 4,5
![Page 9: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/9.jpg)
Fall 2005 9
5
8
10
9
6
7
2
3
4
1
6,7,8,9,10
4,5
1,2 3
![Page 10: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/10.jpg)
Fall 2005 10
5
8
10
9
6
7
2
3
4
1
6,7,8,9,10
4,5
3
1 2
![Page 11: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/11.jpg)
Fall 2005 11
5
8
10
9
6
7
2
3
4
1
6,7,8,9,10
3
1 2
4 5
![Page 12: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/12.jpg)
Fall 2005 12
Range Search Kd-Tree
Idea: Traverse the kd-tree; visit only nodes wh
ose region intersected by query rectangle If region is fully contained, report the sub
tree If leaf is reached, query the point against
the range
![Page 13: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/13.jpg)
Fall 2005 13
Algorithm v
lc(v) rc(v)
v
lc(v)
rc(v)
![Page 14: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/14.jpg)
Fall 2005 14
Examplel1 l1
l2
l2 l3
l3
![Page 15: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/15.jpg)
Fall 2005 15
Region Intersection & Containment
Each node in kd-tree implies a region in 2D (k-d in general): [xl,xh]×[yl,yh] Each region can be derived from the defining vert
ex and region of parent Note: the region can be unbounded
The query rectangle: [x, x’]×[y, y’]Containment: [xl,xh] [x, x’] [yl,yh] [y, y’]
Intersection test can be done in a similar way
![Page 16: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/16.jpg)
Fall 2005 16
Example
2
3
4
1
1(-4,0)2(0,3)3(1,2)4(3,-3)
1 2
3 4
(-,0]×(-,)
(-,)×(-,)
![Page 17: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/17.jpg)
Fall 2005 17
Example
2
3
4
1
1(-4,0)2(0,3)3(1,2)4(3,-3)
1 2
3 4
(-,0]×(-,)
(-,)×(-,)
(-,0]×(-,0]
![Page 18: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/18.jpg)
Fall 2005 18
Example
2
3
4
1
1(-4,0)2(0,3)3(1,2)4(3,-3)
1 2
3 4
(-,)×(-,)
(0,)×(-,)
![Page 19: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/19.jpg)
Fall 2005 19
Example
2
3
4
1
1(-4,0)2(0,3)3(1,2)4(3,-3)
1 2
3 4
(-,)×(-,)
(0,)×(-,)
(0,)×(-3,)
![Page 20: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/20.jpg)
Fall 2005 20
Homework
Research on linear algorithm for median finding. Write a summary.
Build a kd-tree of the points on the following page. Do the range query according to the algorithm on p.13 Detail the region of each node and intersection/
containment check
![Page 21: Fall 20051 Orthogonal Range Search deBerg et. al (Chap.5)](https://reader035.vdocuments.net/reader035/viewer/2022081603/56649f155503460f94c2a543/html5/thumbnails/21.jpg)
Fall 2005 21
a
h
b
d
g
fc
e
Read off coordinate from the sketching layout, e.g., a=(-4,2)Query rectangle = [-2,4]×[-1,3]