1 / 37

Finding Objects

Finding Objects. Shmuel Wimer Bar Ilan Univ., School of Engineering. Here is a floor (can also be space). Objects are located in the room. The Problem. What objects located here?. Need efficient way to store objects and apply queries. Outline. 1D range search 2D Kd-Tree 2D Range Tree

solada
Download Presentation

Finding Objects

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. Finding Objects Shmuel Wimer Bar Ilan Univ., School of Engineering Finding objects

  2. Here is a floor (can also be space) Objects are located in the room The Problem What objects located here? Need efficient way to store objects and apply queries Finding objects

  3. Outline • 1D range search • 2D Kd-Tree • 2D Range Tree • Accelerating 2D Query Time • Layered Range Tree Finding objects

  4. 49 23 80 37 10 62 89 3 19 100 70 30 59 89 49 3 10 19 23 30 37 59 62 70 80 100 105 1D Range Tree Finding objects

  5. 1D Range Searching Finding objects

  6. 49 23 80 37 10 62 89 3 19 100 70 30 59 89 49 3 10 19 23 30 37 59 62 70 80 100 105 searching paths reported points Finding objects

  7. Finding objects

  8. Finding objects

  9. Finding objects

  10. Correctness of Query Algorithm Finding objects

  11. Finding objects

  12. Finding objects

  13. Finding objects

  14. y’’ p y(p) y’ x’ x(p) x’’ 2D Kd-Tree Ptop Key idea: splitting points in alternating directions Pright Pleft Pbottom Finding objects

  15. l5 l1 l3 l7 l6 l5 l2 l8 l9 l1 l4 l7 p4 p5 p9 p10 p2 l2 l3 p7 l8 p1 p8 p3 p6 l9 p9 p4 p8 p10 p3 p5 l4 l6 p6 p7 p1 p2 Vertical and horizontal splits are alternating. Points on split lines belong to lower left regions. Split ends when region contains one point. We assume without loss of generality that all coordinates are distinct. Finding objects

  16. Finding objects

  17. Construction Time and Storage Finding objects

  18. Finding objects

  19. l1 l1 l2 l2 l3 v l3 region (v) Querying Every internal node of Kd-tree stores a region of xy plane defined by the path to root. Regions are defined in O(1) time per node at construction. Finding objects

  20. l1 l1 l2 l2 l3 v l3 region (v) If node’s region is disjoint to a query rectangle, no point in node’s sub-tree satisfies the query. If query rectangle contains node’s region all points in node’s sub-tree satisfy the query. Otherwise search must proceed. Finding objects

  21. p4 p5 p12 p13 p2 p8 p10 p12 p4 p11 p13 p3 p5 p1 p11 p3 p9 p6 p1 p2 p7 p6 p7 p8 p9 p10 Finding objects

  22. Finding objects

  23. Finding objects

  24. Reminder of 1D Range Tree Objects are stored in leaves of balanced binary tree. Internal nodes store search directives. Starts search at root until node’s key falls in range. Left path is issued from forking node down to left end of range. All right sub-trees are reported. Similar for right path. Finding objects

  25. 2D Range Tree [x`,x``] × [y`,y``] is a range query. In 1D range tree P ( V ), the points stored at leaves of T(V), is called the canonical subset of V. P (root) is all points,P (leaf) is a single point. In 1D range tree points in [x`,x``] are obtained from O (log n) disjoint sub-trees (right sub-trees of left path and left sub-trees of right path). Hence [y`, y``] query further looks into P (V). Construct 2-level data structure: Binary search tree T built on x-coordinate of P. For any node V store P (V) in an associated binary tree Tassoc (V) built on y-coordinate of points. Finding objects

  26. Finding objects

  27. Finding objects

  28. p p p p Storage and Construction Time A point p is stored in log n associated trees. The size of associated tree (binary) is linear in number of stored points Associated trees at a level of primary tree are disjoint, hence total storage consumed at a level is O(n) Finding objects

  29. 2D range tree requires O(nlogn) storage Construction described in Build_2D_RangeTree is not efficient as it takes O(nlogn) time to build the associated trees, thus resulting in O(nlog2n) time. Total construction time can be reduced to O(nlogn) by pre-sorting of the points by y-coordinate and then building the 2D range tree bottom-up rather than top-down. Finding objects

  30. Finding objects

  31. Query Time Finding objects

  32. 3 10 19 23 30 37 59 62 70 80 100 105 A1 10 19 30 62 70 80 100 A2 Accelerating 2D Query Time S1 – set of objects ordered in an array A1 S2 – subset of S1, ordered in an array A2 Reporting objects of S1 in range 20to75 Find 23 by binary search, then traverse and report until 70 in O(logn+k)time Reporting objects from S2 can save binary search ! Every object in A1 points to the smallest object in A2 larger or equal to it. Use NIL if such one does not exist. This is only O(k)time ! Finding objects

  33. 17 8 52 5 15 33 58 17 62 58 59 2 7 12 21 41 67 2 19 5 80 7 10 8 37 12 3 15 99 21 49 33 30 41 95 52 23 67 89 93 70 Observation: The canonical sub-set P(LSON[V]) and the canonical sub-set P(RSON[V]) are canonical sub-set of P(V) Finding objects

  34. Implementation • T is a range tree of P of n points. • P (V) is canonical point set stored in leaves of T(V) • Instead of storing P(V) in associated tree sorted by y-coordinate, it is stored in an array A(V) sorted by y-coordinate. • Each entry in A(V) maintains two pointers: • One to an entry in A(LSON[V]) (the smallest equal or larger) • One to an entry in A(RSON [V]) (the smallest equal or larger) • Reporting from node V is done directly from A(V) rather than by T(V) traversal. Finding objects

  35. 3 10 19 23 30 37 49 59 62 70 80 89 95 99 3 10 19 37 62 80 99 10 19 37 80 23 30 49 95 23 30 49 59 70 89 95 3 99 30 49 23 95 70 89 19 80 3 62 99 59 70 89 10 37 19 80 10 37 3 99 49 30 95 23 89 70 Layered Range Tree 62 59 Finding objects

  36. Performance of Layered Range Tree • [x`,x``]×[y`,y``] is a range query. • Perform x-range search on primary tree T to determine left and right paths down to leaves x` and x`` in O(logn) time. Points of canonical subsets adhere [x`,x``]. This takes O(logn). • We find in A[Vsplit] the smallest entry of [y`,y``] in O(logn) time. • Reports take place from A[V] in right nodes of left path and left nodes of right path. The smallest entry of [y`,y``] is found in constant time by the pointer to parents propagating up to Vsplit. Finding objects

  37. Report time per node is O(1+kV), yielding a total of O(logn+k), compared to O (log2n+k) in 2D range tree. • Storage is O(nlogn) same as 2D range tree. • Construction time is O(nlogn) as in 2D range tree. • Sort initially all objects by y-coordinate stored in an array with pointers to objects in primary binary tree T. • Every split to left and right sub-trees in T is followed by linear traversal of A (Vparent) and split into sorted A(Vleft) and A (Vright) according to the split made by x-coordinate in T. • Total work per level of T to construct all A(V) is O(n). Finding objects

More Related