Mehdi Mohammadi March 2015 1 Western Michigan University Department of Computer Science CS 6310 - Advanced Data Structure.

Slides:



Advertisements
Similar presentations
Introduction to Algorithms
Advertisements

Two Segments Intersect?
Orthogonal range searching. The problem (1-D) Given a set of points S on the line, preprocess them to build structure that allows efficient queries of.
INTERVAL TREE & SEGMENTATION TREE
 Definition of B+ tree  How to create B+ tree  How to search for record  How to delete and insert a data.
An Optimal Dynamic Interval Stabbing-Max Data Structure? Pankaj K. Agarwal, Lars Arge and Ke Yi Department of Computer Science Duke University.
Augmenting Data Structures Advanced Algorithms & Data Structures Lecture Theme 07 – Part I Prof. Dr. Th. Ottmann Summer Semester 2006.
Dynamic Planar Convex Hull Operations in Near- Logarithmic Amortized Time TIMOTHY M. CHAN.
I/O-Algorithms Lars Arge Fall 2014 September 25, 2014.
2/14/13CMPS 3120 Computational Geometry1 CMPS 3120: Computational Geometry Spring 2013 Planar Subdivisions and Point Location Carola Wenk Based on: Computational.
COSC 6114 Prof. Andy Mirzaian. References: [M. de Berge et al] chapter 5 Applications: Data Base GIS, Graphics: crop-&-zoom, windowing.
Multidimensional Indexing
CS 171: Introduction to Computer Science II
Orthogonal Range Searching 3Computational Geometry Prof. Dr. Th. Ottmann 1 Orthogonal Range Searching 1.Linear Range Search : 1-dim Range Trees 2.2-dimensional.
2-dimensional indexing structure
I/O-Algorithms Lars Arge University of Aarhus February 21, 2005.
I/O-Algorithms Lars Arge Aarhus University February 27, 2007.
I/O-Algorithms Lars Arge Spring 2011 March 8, 2011.
Optimal Planar Point Enclosure Indexing Lars Arge, Vasilis Samoladas and Ke Yi Department of Computer Science Duke University Technical University of Crete.
Orthogonal Range Searching-1Computational Geometry Prof. Dr. Th. Ottmann 1 Orthogonal Range Searching 1.Linear Range Search : 1-dim Range Trees 2.2-dimensional.
Computational Geometry, WS 2007/08 Lecture 15 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften.
I/O-Algorithms Lars Arge Aarhus University February 13, 2007.
I/O-Algorithms Lars Arge Aarhus University February 16, 2006.
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.
Lars Arge1, Mark de Berg2, Herman Haverkort3 and Ke Yi1
I/O-Algorithms Lars Arge Aarhus University March 5, 2008.
I/O-Efficient Structures for Orthogonal Range Max and Stabbing Max Queries Second Year Project Presentation Ke Yi Advisor: Lars Arge Committee: Pankaj.
I/O-Algorithms Lars Arge Aarhus University March 9, 2006.
1 Geometric index structures April 15, 2004 Based on GUW Chapter , [Arge01] Sections 1, 2.1 (persistent B- trees), 3-4 (static versions.
Lecture 11 : More Geometric Data Structures Computational Geometry Prof. Dr. Th. Ottmann 1 Geometric Data Structures 1.Rectangle Intersection 2.Segment.
R-Trees 2-dimensional indexing structure. R-trees 2-dimensional version of the B-tree: B-tree of maximum degree 8; degree between 3 and 8 Internal nodes.
O RTHOGONAL R ANGE S EARCHING الهه اسلامی فروردین 92, 1.
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.
Binary Trees Chapter 6.
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.
1 Geometric Intersection Determining if there are intersections between graphical objects Finding all intersecting pairs Brute Force Algorithm Plane Sweep.
Chapter Tow Search Trees BY HUSSEIN SALIM QASIM WESAM HRBI FADHEEL CS 6310 ADVANCE DATA STRUCTURE AND ALGORITHM DR. ELISE DE DONCKER 1.
UNC Chapel Hill M. C. Lin Point Location Reading: Chapter 6 of the Textbook Driving Applications –Knowing Where You Are in GIS Related Applications –Triangulation.
Chapter 19: Binary Trees. Objectives In this chapter, you will: – Learn about binary trees – Explore various binary tree traversal algorithms – Organize.
Database Management 9. course. Execution of queries.
UNC Chapel Hill M. C. Lin Orthogonal Range Searching Reading: Chapter 5 of the Textbook Driving Applications –Querying a Database Related Application –Crystal.
External Memory Algorithms for Geometric Problems Piotr Indyk (slides partially by Lars Arge and Jeff Vitter)
14/13/15 CMPS 3130/6130 Computational Geometry Spring 2015 Windowing Carola Wenk CMPS 3130/6130 Computational Geometry.
Chapter 6 Binary Trees. 6.1 Trees, Binary Trees, and Binary Search Trees Linked lists usually are more flexible than arrays, but it is difficult to use.
Multi-dimensional Search Trees
Lars Arge Presented by Or Ozery. I/O Model Previously defined: N = # of elements in input M = # of elements that fit into memory B = # of elements per.
2IL50 Data Structures Fall 2015 Lecture 9: Range Searching.
Starting at Binary Trees
Lecture 2: External Memory Indexing Structures CS6931 Database Seminar.
Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930.
Segment Trees Basic data structure in computational geometry. Computational geometry.  Computations with geometric objects.  Points in 1-, 2-, 3-, d-space.
Multi-dimensional Search Trees CS302 Data Structures Modified from Dr George Bebis.
Spatial Indexing Techniques Introduction to Spatial Computing CSE 5ISC Some slides adapted from Spatial Databases: A Tour by Shashi Shekhar Prentice Hall.
Interval S = [3,10]  {x | 3 ≤ x ≤ 10} Closed segment S = (3,10)  {x | 3 < x < 10} Opened segment S = [3,3]  {3} Point.
Lecture 9COMPSCI.220.FS.T Lower Bound for Sorting Complexity Each algorithm that sorts by comparing only pairs of elements must use at least 
CMPS 3130/6130 Computational Geometry Spring 2015
UNC Chapel Hill M. C. Lin Geometric Data Structures Reading: Chapter 10 of the Textbook Driving Applications –Windowing Queries Related Application –Query.
Mehdi Kargar Department of Computer Science and Engineering
School of Computing Clemson University Fall, 2012
Lecture 3: Parallel Algorithm Design
Geometric Data Structures
CMPS 3130/6130 Computational Geometry Spring 2017
Orthogonal Range Searching and Kd-Trees
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]
CMPS 3130/6130 Computational Geometry Spring 2017
File Processing : Multi-dimensional Index
CMPS 3130/6130 Computational Geometry Spring 2017
Tree Structures for Set of Intervals
Presentation transcript:

Mehdi Mohammadi March Western Michigan University Department of Computer Science CS Advanced Data Structure

 Orthogonal Range Trees  Higher-Dimensional Segment Trees  Other Systems of Building Blocks  Range-Counting and the Semigroup Model  KD-Trees and Related Structures 2

 Orthogonal Range-Searching problem ◦ Input: a (d-dimensional) box, a set of points ◦ Output: all the points in the set that lies in that box  Applications ◦ Geometric applications ◦ Database Queries  Select Emp from T where 50K<Salary<75K AND age > 50 AND salesAmount > 500K AND 2011<salesYear<2015  A 5-d orthogonal range query ◦ Preprocessing for queries 3

 General situation ◦ Set of data points p 1, …, p n  P i = (p i1, …, p id ) ◦ d-dimensional query interval [a 1,b 1 [ ×…×[a d,b d [ ◦ Return all points p i contained in that interval:  a 1 ≤p i1 <b 1, …, a d ≤ p id <b d  O(f d (n) + k)  Structure ◦ Build a balanced search tree for the first coordinates of data points  Each node has its Associated Interval: points whose first coordinate falls into that interval  Build recursively a range search tree for the remaining d-1 coordinates on each node 4

 Query: ◦ find O(log n) nodes correspond to [a 1,b 1 [ ◦ In each of those nodes perform d-1 dimensional range search for [a 2,b 2 [ × … × [a d, b d [ 5

 Example 2-d ◦ (0,1), (1,5), (2,8), (3,3), (5,0), (6,4), (7,6), (8,7), (9,9) 6 1-d range tree {(2,8)} {(1,5)} {(1,5), (2,8)} {(0,1)} {(0,1), (1,5), (2,8)}

 Theorem: Orthogonal search trees are static structure supporting d-dimensional range queries in a set of d-dimensional points ◦ Query time  Output sensitive time  O((log n) d + k) if output consists of k points ◦ Building tree time  O(n(log n) d ) ◦ Space requirement  O(n(log n) d-1 ) 7

 Fractional Cascading ◦ When we make a sequence of searches in different but related sets, we can use the information of search in previous set into the next set.  Algorithm ◦ For each node, sort the Associated Intervals by second coordinate ◦ Link each point on this list to  The same point on the left or right lower neighbor  The point with the next smaller second coordinate if the point is missing on that side  Or the first point on the list if there is no point with smaller coordinate 8

 Fractional Cascading 9

 Fractional Cascading Search ◦ We have a search tree for the first coordinate  We have to select the corresponding nodes to the canonical interval decomposition of the first interval query ◦ Attached to each node is a structure for the search in the second coordinate  These structure are linked together for fractional cascading ◦ So that we need to search only in the set associated with the first node  Then reuse that information in all later searches 10

 Theorem: Orthogonal range trees with fractional cascading are a static data structure that support d-dimensional orthogonal range queries in a set of d- dimensional point (d>1); ◦ Query time  O((log n) d-1 + k) if output consists of k points ◦ Building tree time  O(n(log n) d-1 ) ◦ Space requirement  O(n(log n) d-1 ) 11

 The inverse problem of orthogonal range searching problem  Input: ◦ A set of n ranges (d-dimensional intervals) ◦ A query point  Output: ◦ All ranges that contain that point  Solvable by generalization over segment tree ◦ It is defined recursively 12

 Main structure: ◦ A balanced search tree whose keys are the first coordinates of d-dimensional intervals ◦ Each node of that tree contains a d-1 dimensional segment tree. ◦ In this d-1 dimensional segment tree associated with node p, all intervals are stored for which p is part of the canonical interval decomposition of the first dimension. 13

 Query ◦ Follow the search path of the first coordinate of the query point ◦ In each node perform a (d-1) dimensional query with the remaining coordinates associated with the node.  Theorem: d-dimensional segment tree is a static data structure that lists all d-dimensional intervals containing a given query key, ◦ Build time: O(n(log n) d ) ◦ Space need: O(n(log n) d ) ◦ Query time: O((log n) d + k) if there are k such intervals 14

 Improvement: S-tree using fractional cascading  Algorithm ◦ Input: rectangles [a i,b i [ × [c i,d i [ for i = 1,…, n  1. create balanced search tree T1 for {a 1,b 1,a 2,b 2,…,a n,b n }  2. attach an empty secondary balanced tree to each node of the first tree  3. for i=1 to n ◦ 3.1 start from T1 root, put it on a stack. ◦ 3.2 Repeat As long as stack is not empty  Take the current node v from the stack  Insert {c i, d i } as keys into the tree T2(v) 15

 If intervalOf(v) is not in [a i,b i [, check v’s left and right subtrees.  If their intervals have some intersection with [a i,b i [, then put them on the stack.  4. for each i=1,…n ◦ 4.1. for all nodes v that belong to the canonical interval decomposition of [a i,b i [ in T1  Insert rectangle [a i,b i [ × [c i,d i [ into the segment tree T2(v) 16

 5. for each node v of T1 ◦ Create pointers from each leaf of T2(v) to the corresponding leaves of T2(v->left) and T2(v->right)  6. for each node v of T1 ◦ For each node w of T2(v) create a pointer to the next node above w in T2(v) that has some rectangle associated with it.  Theorem: S-tree is a static data structure that keeps track of a set of n rectangles, and for a given point list all rectangles containing that point ◦ Space: O(n(log n) 2 ) ◦ Query time: O(log n + k); if there are k output intervals 17

 Canonical interval decomposition ◦ Decompose an interval in a union of a small number of building blocks  To answer a query interval ◦ Decompose the query interval into a union of building blocks ◦ Execute the query on those building blocks. 18

 Building block query requires ◦ Decompose the queries ◦ Reconstruct the answer from the answer of building blocks ◦ Also, some structure that answers the query for a fixed block ◦ Represent each interval as a union of a small number of blocks  Choice of building blocks tradeoff ◦ Reduce interval query to a small number of blocks needs many building blocks  For each block we have to build a structure to answer queries 19

 Bentley and Maurer (1980) proposal ◦ Use an r-level structure for system of blocks  Interpreted as writing numbers to the base n (1/r). 20 Intervals of blocks for top level [an (1-1/r), bn (1-1/r) ] 0≤a<b≤n 1/r O(n 2/r ) blocks O(n (j+1)/r ) blocks

 Using r-level blocking we obtain a structure to perform d-dimensional orthogonal range searching ◦ Query time: O(r d log n + k) ◦ Preprocessing time: O(r d n 1+(2d-2)/r log n) ◦ Query time is output sensitive for large r and n. 21

 Range counting problem ask just for the number of points in a range ◦ We do not need output sensitive time complexity  Use orthogonal range tree ◦ Instead of concatenating lists, just add up numbers ◦ Generalization by giving weight to points  In 1-dimensional version, just ask for the number of keys in an interval

 All operations in O(n(log n) d ) for a set of n points  Difference with range searching ◦ Allow to make dynamic structure  Insertion, deletion and rebalance  Range searching has large associated trees for nodes ◦ lower bounds for operations are possible: O((log n) d )  In the semigroup version ◦ a commutative semigroup (S,+) is specified, ◦ each point is assigned a weight from S, ◦ Return semigroup sum of the weights of the keys in an interval  Directly from canonical interval decomposition 23

 Another structure to support orthogonal range searching ◦ Easy to understand and implement ◦ Unsatisfactory performance  2-dimensional  KD-Tree:O(n 1/2 + k)  Orthogonal range tree: O((log n) 2 + k)  d-dimensional  KD-Tree: O(n 1-1/d + k)  Orthogonal range tree: O((log n) d + k) 24

 In each node make a comparison to enter the left or right sub-trees ◦ In different levels compare against different coordinates  In the root compare against x  In the second level compare against y, and so on. 25

 Building KD-Tree 26

 Building KD-Tree 27

 KD-Tree range query ◦ Starting in the root, descend into each node whose node interval has an intersection with the query region ◦ Stop branches when an intersection is empty  Time complexity is as large as Ω(√n) ◦ Even in completely balanced tree with distinct keys ◦ This bound cannot be improved 28

 Theorem: KD-Trees are a static data structure that supports d-dimensional or orthogonal range queries in a set of d-dimensional points ◦ output sensitive time O(n 1-1/d + k) if output consist of k points ◦ Can be built in O(n (log n)) ◦ Need space O(n) 29

Thank you for your attention 30