Shmuel Wimer Bar Ilan Univ., School of Engineering

Slides:



Advertisements
Similar presentations
Transform and Conquer Chapter 6. Transform and Conquer Solve problem by transforming into: a more convenient instance of the same problem (instance simplification)
Advertisements

Augmenting Data Structures Advanced Algorithms & Data Structures Lecture Theme 07 – Part I Prof. Dr. Th. Ottmann Summer Semester 2006.
I/O-Algorithms Lars Arge Fall 2014 September 25, 2014.
COSC 6114 Prof. Andy Mirzaian. References: [M. de Berge et al] chapter 5 Applications: Data Base GIS, Graphics: crop-&-zoom, windowing.
Visibility Graphs May Shmuel Wimer Bar-Ilan Univ., Eng. Faculty Technion, EE Faculty.
B+-Trees (PART 1) What is a B+ tree? Why B+ trees? Searching a B+ tree
Convex Hulls May Shmuel Wimer Bar Ilan Univ., Eng. Faculty Technion, EE Faculty.
AA Trees another alternative to AVL trees. Balanced Binary Search Trees A Binary Search Tree (BST) of N nodes is balanced if height is in O(log N) A balanced.
Orthogonal Range Searching 3Computational Geometry Prof. Dr. Th. Ottmann 1 Orthogonal Range Searching 1.Linear Range Search : 1-dim Range Trees 2.2-dimensional.
Orthogonal Range Searching Computational Geometry, WS 2006/07 Lecture 13 – Part III Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für.
I/O-Algorithms Lars Arge University of Aarhus March 1, 2005.
I/O-Algorithms Lars Arge Spring 2009 March 3, 2009.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Part B Part A:  Index Definition in SQL  Ordered Indices  Index Sequential.
O RTHOGONAL R ANGE S EARCHING الهه اسلامی فروردین 92, 1.
Homework #3 Due Thursday, April 17 Problems: –Chapter 11: 11.6, –Chapter 12: 12.1, 12.2, 12.3, 12.4, 12.5, 12.7.
Fractional Cascading and Its Applications G. S. Lueker. A data structure for orthogonal range queries. In Proc. 19 th annu. IEEE Sympos. Found. Comput.
AALG, lecture 11, © Simonas Šaltenis, Range Searching in 2D Main goals of the lecture: to understand and to be able to analyze the kd-trees and.
1 CS 728 Advanced Database Systems Chapter 17 Database File Indexing Techniques, B- Trees, and B + -Trees.
Orthogonal Range Searching I Range Trees. Range Searching S = set of geometric objects Q = query object Report/Count objects in S that intersect Q Query.
Randomized Algorithms - Treaps
 B+ Tree Definition  B+ Tree Properties  B+ Tree Searching  B+ Tree Insertion  B+ Tree Deletion.
March Trapezoidal Maps Shmuel Wimer Bar Ilan Univ., School of Engineering.
UNC Chapel Hill M. C. Lin Orthogonal Range Searching Reading: Chapter 5 of the Textbook Driving Applications –Querying a Database Related Application –Crystal.
14/13/15 CMPS 3130/6130 Computational Geometry Spring 2015 Windowing Carola Wenk CMPS 3130/6130 Computational Geometry.
2IL50 Data Structures Fall 2015 Lecture 9: Range Searching.
Orthogonal Range Search
Binary Search Trees (BST)
CMPS 3130/6130 Computational Geometry Spring 2015
Trees By JJ Shepherd. Introduction Last time we discussed searching and sorting in a more efficient way Divide and Conquer – Binary Search – Merge Sort.
UNC Chapel Hill M. C. Lin Geometric Data Structures Reading: Chapter 10 of the Textbook Driving Applications –Windowing Queries Related Application –Query.
May 2012Range Search Algorithms1 Shmuel Wimer Bar Ilan Univ. Eng. Faculty Technion, EE Faculty.
Indexing Structures for Files
CSE 554 Lecture 5: Contouring (faster)
Chapter Outline Indexes as additional auxiliary access structure
AA Trees.
Lecture 3: Parallel Algorithm Design
Geometric Data Structures
Top 50 Data Structures Interview Questions
Multiway Search Trees Data may not fit into main memory
CS 728 Advanced Database Systems Chapter 18
Indexing ? Why ? Need to locate the actual records on disk without having to read the entire table into memory.
CMPS 3130/6130 Computational Geometry Spring 2017
Extra: B+ Trees CS1: Java Programming Colorado State University
Spatial Indexing I Point Access Methods.
B+ Tree.
KD Tree A binary search tree where every node is a
Binary Trees, Binary Search Trees
Segment tree and Interval Tree
Orthogonal Range Searching and Kd-Trees
Fast Trie Data Structures
Wednesday, April 18, 2018 Announcements… For Today…
Priority Queues and Heaps
COSC160: Data Structures B-Trees
B+ Trees What are B+ Trees used for What is a B Tree What is a B+ Tree
Multi-Way Search Trees
A Kind of Binary Tree Usually Stored in an Array
B-Tree Insertions, Intro to Heaps
Reporting (1-D) Given a set of points S on the line, preprocess them to build structure that allows efficient queries of the from: Given an interval I=[x1,x2]
Ch. 8 Priority Queues And Heaps
Orthogonal Range Searching Querying a Database
A Robust Data Structure
2-3-4 Trees Red-Black Trees
Data Structures and Algorithms
Trees.
CMPS 3130/6130 Computational Geometry Spring 2017
CMPS 3130/6130 Computational Geometry Spring 2017
Lecture 20: Indexes Monday, February 27, 2006.
B-Trees.
Data Structures and Algorithm Analysis Priority Queues (Heaps)
Data Mining CSCI 307, Spring 2019 Lecture 23
Presentation transcript:

Shmuel Wimer Bar Ilan Univ., School of Engineering Finding Objects Shmuel Wimer Bar Ilan Univ., School of Engineering March 2011 Finding objects

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

Outline 1D range search 2D Kd-Tree 2D Range Tree Accelerating 2D Query Time Layered Range Tree March 2011 Finding objects

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

1D Range Searching March 2011 Finding objects

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

March 2011 Finding objects

March 2011 Finding objects

March 2011 Finding objects

Correctness of Query Algorithm March 2011 Finding objects

March 2011 Finding objects

March 2011 Finding objects

March 2011 Finding objects

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

Vertical and horizontal splits are alternating 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. l5 l1 l7 l1 p3 p2 p4 p5 p9 p7 p8 p6 p1 p10 l2 l3 l2 l4 l3 l4 l5 l6 l7 l6 l8 l8 p3 p4 p5 l9 p8 p9 p10 l9 p1 p2 p6 p7 March 2011 Finding objects

March 2011 Finding objects

Construction Time and Storage March 2011 Finding objects

March 2011 Finding objects

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. l1 l2 l3 region (v) v l1 l2 l3 March 2011 Finding objects

l1 l2 l3 region (v) v l1 l2 l3 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. March 2011 Finding objects

p13 p11 p12 p3 p5 p4 p1 p6 p2 p8 p7 p10 p9 p3 p2 p4 p5 p12 p8 p11 p7 March 2011 Finding objects

March 2011 Finding objects

March 2011 Finding objects

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. March 2011 Finding objects

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. March 2011 Finding objects

March 2011 Finding objects

March 2011 Finding objects

Storage and Construction Time A point p is stored in log n associated trees. p 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) March 2011 Finding objects

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. March 2011 Finding objects

March 2011 Finding objects

Query Time March 2011 Finding objects

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 20 to 75 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 ! 3 10 19 23 30 37 59 62 70 80 100 105 A1 10 19 30 62 70 80 100 A2 March 2011 Finding objects

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

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. March 2011 Finding objects

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

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. March 2011 Finding objects

Storage is O(nlogn) same as 2D range tree. 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). March 2011 Finding objects