computational geometry
play

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


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

  2. Motivation Interval trees Windowing queries Priority search trees Windowing Zoom in; re-center and zoom in; select by outlining Computational Geometry Lecture 14: Windowing queries

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

  4. Motivation Interval trees Windowing queries Priority search trees 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

  5. Motivation Interval trees Windowing queries Priority search trees Windowing How can a rectangle and an axis-parallel line segment intersect? Computational Geometry Lecture 14: Windowing queries

  6. Motivation Interval trees Windowing queries Priority search trees Windowing Essentially two types: Segments whose endpoint lies in the rectangle (or both endpoints) Segments with both endpoints outside 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

  7. Motivation Interval trees Windowing queries Priority search trees 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

  8. Motivation Interval trees Windowing queries Priority search trees 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

  9. Motivation Interval trees Windowing queries Priority search trees 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

  10. Motivation Interval trees Windowing queries Priority search trees 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

  11. Motivation Interval trees Windowing queries Priority search trees 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

  12. Motivation Interval trees Windowing queries Priority search trees 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

  13. Motivation Definition Interval trees Querying Priority search trees 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

  14. Motivation Definition Interval trees Querying Priority search trees Construction Splitting a set of intervals The median x of the 2 n endpoints partitions the intervals into three subsets: Intervals I left fully left of x Intervals I mid that contain (intersect) x Intervals I right fully right of x x Computational Geometry Lecture 14: Windowing queries

  15. Motivation Definition Interval trees Querying Priority search trees Construction Interval tree: recursive definition The interval tree for I has a root node ν that contains x and the intervals I left are stored in the left subtree of ν the intervals I mid are stored with ν the intervals I right are stored in the right subtree of ν The left and right subtrees are proper interval trees for I left and I right How many intervals can be in I mid ? How should we store I mid ? Computational Geometry Lecture 14: Windowing queries

  16. Motivation Definition Interval trees Querying Priority search trees Construction Interval tree: left and right lists How is I mid 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

  17. Motivation Definition Interval trees Querying Priority search trees Construction Interval tree: left and right lists x Make a list L left using the left-to-right order of the left endpoints of I mid Make a list L right using the right-to-left order of the right endpoints of I mid Store both lists as associated structures with ν Computational Geometry Lecture 14: Windowing queries

  18. Motivation Definition Interval trees Querying Priority search trees Construction Interval tree: example s 5 , s 6 , s 7 L left L right s 7 , s 5 , s 6 s 4 , s 3 , s 2 s 4 , s 3 , s 2 s 9 , s 10 s 9 , s 10 s 1 s 8 s 12 , s 11 s 1 s 8 s 11 , s 12 s 2 s 3 s 6 s 7 s 10 s 12 s 5 s 1 s 4 s 8 s 9 s 11 Computational Geometry Lecture 14: Windowing queries

  19. Motivation Definition Interval trees Querying Priority search trees Construction Interval tree: storage The main tree has O ( n ) nodes The total length of all lists is 2 n because each interval is stored exactly twice: in L left and L right and only at one node Consequently, the interval tree uses O ( n ) storage Computational Geometry Lecture 14: Windowing queries

  20. Motivation Definition Interval trees Querying Priority search trees Construction Interval querying Algorithm QueryIntervalTree ( ν , q x ) 1. if ν is not a leaf 2. then if q x < x mid ( ν ) 3. then Traverse list L left ( ν ) , starting at the interval with the leftmost endpoint, reporting all the intervals that contain q x . Stop as soon as an interval does not contain q x . 4. QueryIntervalTree ( lc ( ν ) , q x ) 5. else Traverse list L right ( ν ) , starting at the interval with the rightmost endpoint, reporting all the intervals that contain q x . Stop as soon as an interval does not contain q x . 6. QueryIntervalTree ( rc ( ν ) , q x ) Computational Geometry Lecture 14: Windowing queries

  21. Motivation Definition Interval trees Querying Priority search trees Construction Interval tree: query example s 5 , s 6 , s 7 L left L right s 7 , s 5 , s 6 s 4 , s 3 , s 2 s 4 , s 3 , s 2 s 9 , s 10 s 9 , s 10 s 1 s 8 s 12 , s 11 s 1 s 8 s 11 , s 12 s 2 s 3 s 6 s 7 s 10 s 12 s 5 s 1 s 4 s 8 s 9 s 11 Computational Geometry Lecture 14: Windowing queries

  22. Motivation Definition Interval trees Querying Priority search trees Construction Interval tree: query example s 5 , s 6 , s 7 L left L right s 7 , s 5 , s 6 s 4 , s 3 , s 2 s 4 , s 3 , s 2 s 9 , s 10 s 9 , s 10 s 1 s 8 s 12 , s 11 s 1 s 8 s 11 , s 12 s 2 s 3 s 6 s 7 s 10 s 12 s 5 s 1 s 4 s 8 s 9 s 11 Computational Geometry Lecture 14: Windowing queries

  23. Motivation Definition Interval trees Querying Priority search trees Construction Interval tree: query example s 5 , s 6 , s 7 L left L right s 7 , s 5 , s 6 s 4 , s 3 , s 2 s 4 , s 3 , s 2 s 9 , s 10 s 9 , s 10 s 1 s 8 s 12 , s 11 s 1 s 8 s 11 , s 12 s 2 s 3 s 6 s 7 s 10 s 12 s 5 s 1 s 4 s 8 s 9 s 11 Computational Geometry Lecture 14: Windowing queries

  24. Motivation Definition Interval trees Querying Priority search trees Construction Interval tree: query example s 5 , s 6 , s 7 L left L right s 7 , s 5 , s 6 s 4 , s 3 , s 2 s 4 , s 3 , s 2 s 9 , s 10 s 9 , s 10 s 1 s 8 s 12 , s 11 s 1 s 8 s 11 , s 12 s 2 s 3 s 6 s 7 s 10 s 12 s 5 s 1 s 4 s 8 s 9 s 11 Computational Geometry Lecture 14: Windowing queries

  25. Motivation Definition Interval trees Querying Priority search trees Construction Interval tree: query example s 5 , s 6 , s 7 L left L right s 7 , s 5 , s 6 s 4 , s 3 , s 2 s 4 , s 3 , s 2 s 9 , s 10 s 9 , s 10 s 1 s 8 s 12 , s 11 s 1 s 8 s 11 , s 12 s 2 s 3 s 6 s 7 s 10 s 12 s 5 s 1 s 4 s 8 s 9 s 11 Computational Geometry Lecture 14: Windowing queries

Recommend


More recommend