CMPS 3130/6130 Computational Geometry Spring 2015

Slides:



Advertisements
Similar presentations
Introduction to Algorithms
Advertisements

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.
Comp 122, Spring 2004 Binary Search Trees. btrees - 2 Comp 122, Spring 2004 Binary Trees  Recursive definition 1.An empty tree is a binary tree 2.A node.
Trees Types and Operations
Augmenting Data Structures Advanced Algorithms & Data Structures Lecture Theme 07 – Part I Prof. Dr. Th. Ottmann Summer Semester 2006.
COSC 6114 Prof. Andy Mirzaian. References: [M. de Berge et al] chapter 5 Applications: Data Base GIS, Graphics: crop-&-zoom, windowing.
Analysis of Algorithms CS 477/677 Binary Search Trees Instructor: George Bebis (Appendix B5.2, Chapter 12)
B+-Trees (PART 1) What is a B+ tree? Why B+ trees? Searching a B+ tree
Binary Trees, Binary Search Trees CMPS 2133 Spring 2008.
CS 171: Introduction to Computer Science II
9/5/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Plane Sweep Algorithms and Segment Intersection Carola Wenk.
Orthogonal Range Searching 3Computational Geometry Prof. Dr. Th. Ottmann 1 Orthogonal Range Searching 1.Linear Range Search : 1-dim Range Trees 2.2-dimensional.
I/O-Algorithms Lars Arge Aarhus University February 27, 2007.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 11.
Orthogonal Range Searching-1Computational Geometry Prof. Dr. Th. Ottmann 1 Orthogonal Range Searching 1.Linear Range Search : 1-dim Range Trees 2.2-dimensional.
© 2004 Goodrich, Tamassia Binary Search Trees   
Binary Search Trees1 Part-F1 Binary Search Trees   
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.
Geometric Data Structures Computational Geometry, WS 2007/08 Lecture 13 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
I/O-Algorithms Lars Arge Aarhus University March 5, 2008.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Part B Part A:  Index Definition in SQL  Ordered Indices  Index Sequential.
Tirgul 6 B-Trees – Another kind of balanced trees Problem set 1 - some solutions.
Orthogonal Range Searching Computational Geometry, WS 2006/07 Lecture 13 - Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für.
Augmenting Data Structures Advanced Algorithms & Data Structures Lecture Theme 07 – Part II Prof. Dr. Th. Ottmann Summer Semester 2006.
Lecture 11 : More Geometric Data Structures Computational Geometry Prof. Dr. Th. Ottmann 1 Geometric Data Structures 1.Rectangle Intersection 2.Segment.
B + -Trees COMP171 Fall AVL Trees / Slide 2 Dictionary for Secondary storage * The AVL tree is an excellent dictionary structure when the entire.
Balanced Search Trees CS 3110 Fall Some Search Structures Sorted Arrays –Advantages Search in O(log n) time (binary search) –Disadvantages Need.
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.
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.
Indexing. Goals: Store large files Support multiple search keys Support efficient insert, delete, and range queries.
Chapter Tow Search Trees BY HUSSEIN SALIM QASIM WESAM HRBI FADHEEL CS 6310 ADVANCE DATA STRUCTURE AND ALGORITHM DR. ELISE DE DONCKER 1.
CS Data Structures Chapter 15 Trees Mehmet H Gunes
UNC Chapel Hill M. C. Lin Orthogonal Range Searching Reading: Chapter 5 of the Textbook Driving Applications –Querying a Database Related Application –Crystal.
Chapter 12. Binary Search Trees. Search Trees Data structures that support many dynamic-set operations. Can be used both as a dictionary and as a priority.
14/13/15 CMPS 3130/6130 Computational Geometry Spring 2015 Windowing Carola Wenk CMPS 3130/6130 Computational Geometry.
Mehdi Mohammadi March Western Michigan University Department of Computer Science CS Advanced Data Structure.
12.1 Chapter 12: Indexing and Hashing Spring 2009 Sections , , Problems , 12.7, 12.8, 12.13, 12.15,
2IL50 Data Structures Fall 2015 Lecture 9: Range Searching.
Binary Search Tree Qamar Abbas.
Binary Search Trees   . 2 Binary Search Tree Properties A binary search tree is a binary tree storing keys (or key-element pairs) at its.
Lecture 9 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
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.
Lecture 19. Binary Search Tree 1. Recap Tree is a non linear data structure to present data in hierarchical form. It is also called acyclic data structure.
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 
1/20/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Plane Sweep Algorithms I Carola Wenk.
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.
Binary Search Trees < > =
AA Trees.
Geometric Data Structures
Binary Search Trees < > =
CMPS 3130/6130 Computational Geometry Spring 2017
Lecture 7 Algorithm Analysis
CMPS 3130/6130 Computational Geometry Spring 2017
Segment tree and Interval Tree
Orthogonal Range Searching and Kd-Trees
Binary Search Trees < > =
B+ Trees What are B+ Trees used for What is a B Tree What is a B+ Tree
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]
Lecture 7 Algorithm Analysis
Lecture 7 Algorithm Analysis
Binary Search Trees < > =
CMPS 3130/6130 Computational Geometry Spring 2017
Binary Search Trees < > =
CMPS 3130/6130 Computational Geometry Spring 2017
Presentation transcript:

CMPS 3130/6130 Computational Geometry Spring 2015 Orthogonal Range Searching Carola Wenk CMPS 3130/6130 Computational Geometry

Orthogonal range searching Input: n points in d dimensions E.g., representing a database of n records each with d numeric fields Query: Axis-aligned box (in 2D, a rectangle) Report on the points inside the box: Are there any points? How many are there? List the points. CMPS 3130/6130 Computational Geometry

Orthogonal range searching Input: n points in d dimensions Query: Axis-aligned box (in 2D, a rectangle) Report on the points inside the box Goal: Preprocess points into a data structure to support fast queries Primary goal: Static data structure In 1D, we will also obtain a dynamic data structure supporting insert and delete CMPS 3130/6130 Computational Geometry

CMPS 3130/6130 Computational Geometry 1D range searching In 1D, the query is an interval: First solution: Sort the points and store them in an array Solve query by binary search on endpoints. Obtain a static structure that can list k answers in a query in O(k + log n) time. Goal: Obtain a dynamic structure that can list k answers in a query in O(k + log n) time. CMPS 3130/6130 Computational Geometry

CMPS 3130/6130 Computational Geometry 1D range searching In 1D, the query is an interval: New solution that extends to higher dimensions: Balanced binary search tree New organization principle: Store points in the leaves of the tree. Internal nodes store copies of the leaves to satisfy binary search property: Node x stores in key[x] the maximum key of any leaf in the left subtree of x. CMPS 3130/6130 Computational Geometry

Example of a 1D range tree 17 43 1 6 8 12 14 26 35 41 42 59 61 key[x] is the maximum key of any leaf in the left subtree of x. CMPS 3130/6130 Computational Geometry

Example of a 1D range tree 17 8 42 1 14 35 43 6 12 17 26 41 43 59 1 6 8 12 14 26 35 41 42 59 61 key[x] is the maximum key of any leaf in the left subtree of x. CMPS 3130/6130 Computational Geometry

Example of a 1D range query 17 8 42 1 12 8 14 17 26 35 41 14 35 43 6 12 17 26 41 43 59 1 6 8 12 14 26 35 41 42 59 61 RANGE-QUERY([7, 41]) CMPS 3130/6130 Computational Geometry

CMPS 3130/6130 Computational Geometry General 1D range query root split node CMPS 3130/6130 Computational Geometry

Pseudocode, part 1: Find the split node 1D-RANGE-QUERY(T, [x1, x2]) w  root[T] while w is not a leaf and (x2  key[w] or key[w] < x1) do if x2  key[w] then w  left[w] else w  right[w] // w is now the split node [traverse left and right from w and report relevant subtrees] CMPS 3130/6130 Computational Geometry

Pseudocode, part 2: Traverse left and right from split node 1D-RANGE-QUERY(T, [x1, x2]) [find the split node] // w is now the split node if w is a leaf then output the leaf w if x1  key[w]  x2 else v  left[w] // Left traversal while v is not a leaf do if x1  key[v] then output the subtree rooted at right[v] v  left[v] else v  right[v] output the leaf v if x1  key[v]  x2 [symmetrically for right traversal] w CMPS 3130/6130 Computational Geometry

Analysis of 1D-RANGE-QUERY Query time: Answer to range query represented by O(log n) subtrees found in O(log n) time. Thus: Can test for points in interval in O(log n) time. Can report all k points in interval in O(k + log n) time. Can count points in interval in O(log n) time Space: O(n) Preprocessing time: O(n log n) CMPS 3130/6130 Computational Geometry

CMPS 3130/6130 Computational Geometry 2D range trees CMPS 3130/6130 Computational Geometry

CMPS 3130/6130 Computational Geometry 2D range trees Store a primary 1D range tree for all the points based on x-coordinate. Thus in O(log n) time we can find O(log n) subtrees representing the points with proper x-coordinate. How to restrict to points with proper y-coordinate? CMPS 3130/6130 Computational Geometry

CMPS 3130/6130 Computational Geometry 2D range trees Idea: In primary 1D range tree of x-coordinate, every node stores a secondary 1D range tree based on y-coordinate for all points in the subtree of the node. Recursively search within each. CMPS 3130/6130 Computational Geometry

CMPS 3130/6130 Computational Geometry 2D range tree example Secondary trees 5/8 5/8 5/8 8 8 2/7 2/7 2/7 7 6/6 5 6/6 6/6 6 7 3/5 3/5 5 3/5 2 1 6 9/3 5 9/3 3 3 7/2 7/2 7/2 2 1/1 1/1 1/1 5 2 7 1 3 6 9/3 1/1 2/7 3/5 5/8 6/6 7/2 Primary tree CMPS 3130/6130 Computational Geometry

Analysis of 2D range trees Query time: In O(log2 n) = O((log n)2) time, we can represent answer to range query by O(log2 n) subtrees. Total cost for reporting k points: O(k + (log n)2). Space: The secondary trees at each level of the primary tree together store a copy of the points. Also, each point is present in each secondary tree along the path from the leaf to the root. Either way, we obtain that the space is O(n log n). Preprocessing time: O(n log n) CMPS 3130/6130 Computational Geometry

d-dimensional range trees Each node of the secondary y-structure stores a tertiary z-structure representing the points in the subtree rooted at the node, etc. Save one log factor using fractional cascading Query time: O(k + logd n) to report k points. Space: O(n logd – 1 n) Preprocessing time: O(n logd – 1 n) CMPS 3130/6130 Computational Geometry

CMPS 3130/6130 Computational Geometry Search in Subsets Given: Two sorted arrays A1 and A, with A1A A query interval [l,r] Task: Report all elements e in A1 and A with l ≤ e ≤ r Idea: Add pointers from A to A1:  For each aA add a pointer to the smallest element b A1 with ba Query: Find lA, follow pointer to A1. Both in A and A1 sequentially output all elements in [l,r]. Query: [15,40] A 3 10 19 23 30 37 59 62 80 90 10 19 30 62 80 A1 Runtime: O((log n + k) + (1 + k)) = O(log n + k)) CMPS 3130/6130 Computational Geometry

Search in Subsets (cont.) Given: Three sorted arrays A1, A2, and A, with A1 A and A2A Query: [15,40] A 3 10 19 23 30 37 59 62 80 90 10 19 30 62 80 A1 3 23 37 62 90 A2 Runtime: O((log n + k) + (1+k) + (1+k)) = O(log n + k)) Range trees: Y1Y2 Y1 Y2 X CMPS 3130/6130 Computational Geometry

Fractional Cascading: Layered Range Tree Replace 2D range tree with a layered range tree, using sorted arrays and pointers instead of the secondary range trees. Preprocessing: O(n log n) Query: O(log n + k)

Fractional Cascading: Layered Range Tree [12,67]x[19,70] Replace 2D range tree with a layered range tree, using sorted arrays and pointers instead of the secondary range trees. Preprocessing: O(n log n) Query: O(log n + k) x x x x x x x x x CMPS 3130/6130 Computational Geometry

d-dimensional range trees Query time: O(k + logd-1 n) to report k points, uses fractional cascading in the last dimension Space: O(n logd – 1 n) Preprocessing time: O(n logd – 1 n) Best data structure to date: Query time: O(k + logd – 1 n) to report k points. Space: O(n (log n / log log n)d – 1) Preprocessing time: O(n logd – 1 n) CMPS 3130/6130 Computational Geometry