1 / 21

Orthogonal Range Search

Orthogonal Range Search. deBerg et. al (Chap.5). 1D Range Search. Data stored in balanced binary search tree T Input: range tree T and range [x,x ’ ] Output: all points in the range. Find split node

nodin
Download Presentation

Orthogonal Range Search

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Orthogonal Range Search deBerg et. al (Chap.5)

  2. 1D Range Search • Data stored in balanced binary search tree T • Input: range tree T and range [x,x’] • Output: all points in the range

  3. Find split node From split node, find path to m, the node  x; report all right subtree along the path From split node, find path to m’, the node  x’; report all left subtree along the path Check m and m’ split-node x’ x Idea

  4. Performance • T: O(n) storage, built in O(nlogn) • Query: • Worst case: Q(n) … sounds bad • Refined analysis (output-sensitive) • Output k: ReportSubTree O(k) • Traverse tree down to m or m’: O(logn) • Total: O(logn + k)

  5. 2D Kd-tree for 2D range search • Kd-tree: special case of BSP • Input: [x,x’][y,y’] • Output: all points in range

  6. Build kd-tree Break at median n/2 nodes Left (and bottom) child stores the splitting line

  7. Step-by-Step (left subtree) 4 9 6,7,8,9,10 1,2,3,4,5 5 10 2 7 1 8 3 6

  8. 4 9 6,7,8,9,10 5 10 2 4,5 1,2,3 7 1 8 3 6

  9. 4 9 6,7,8,9,10 5 10 2 4,5 7 1 8 3 3 1,2 6

  10. 4 9 6,7,8,9,10 5 10 2 4,5 7 1 8 3 3 6 2 1

  11. 4 9 6,7,8,9,10 5 10 2 7 1 8 3 3 6 5 4 2 1

  12. Range Search Kd-Tree • Idea: • Traverse the kd-tree; visit only nodes whose region intersected by query rectangle • If region is fully contained, report the subtree • If leaf is reached, query the point against the range

  13. Algorithm v lc(v) rc(v) rc(v) v lc(v)

  14. Example l1 l1 l2 l3 l2 l3

  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 vertex 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

  16. 1(-4,0) 2(0,3) 3(1,2) 4(3,-3) 2 3 1 4 Example (-,)×(-,) (-,0]×(-,) 4 3 1 2

  17. 1(-4,0) 2(0,3) 3(1,2) 4(3,-3) 2 3 1 4 Example (-,)×(-,) (-,0]×(-,) 4 3 (-,0]×(-,0] 1 2

  18. 1(-4,0) 2(0,3) 3(1,2) 4(3,-3) 2 3 1 4 Example (-,)×(-,) (0,)×(-,) 4 3 1 2

  19. 1(-4,0) 2(0,3) 3(1,2) 4(3,-3) 2 3 1 4 Example (-,)×(-,) (0,)×(-,) (0,)×(-3,) 4 3 1 2

  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

  21. b a c f e g h d Read off coordinate from the sketching layout, e.g., a=(-4,2) Query rectangle = [-2,4]×[-1,3]

More Related