Computational Geometry, WS 2007/08 Lecture 15 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften.

Slides:



Advertisements
Similar presentations
Introduction to Algorithms
Advertisements

INTERVAL TREE & SEGMENTATION TREE
Line Segment Intersection Computational Geometry, WS 2007/08 Lecture 3 – Supplementary Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut.
1 IP-Lookup and Packet Classification Advanced Algorithms & Data Structures Lecture Theme 08 – Part I Prof. Dr. Th. Ottmann Summer Semester 2006.
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.
COSC 6114 Prof. Andy Mirzaian. References: [M. de Berge et al] chapter 5 Applications: Data Base GIS, Graphics: crop-&-zoom, windowing.
1 Theory I Algorithm Design and Analysis (2 - Trees: traversal and analysis of standard search trees) Prof. Th. Ottmann.
Convex Hulls Computational Geometry, WS 2006/07 Lecture 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
Klee’s Measure Problem Computational Geometry, WS 2007/08 Group Work Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen, Institut.
Linear Programming Computational Geometry, WS 2006/07 Lecture 5, Part IV Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Orthogonal Range Searching Computational Geometry, WS 2006/07 Lecture 13 – Part II Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für.
Delaunay Triangulation Computational Geometry, WS 2006/07 Lecture 11 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
Line Segment Intersection Computational Geometry, WS 2007/08 Lecture 3 – Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Orthogonal Range Searching 3Computational Geometry Prof. Dr. Th. Ottmann 1 Orthogonal Range Searching 1.Linear Range Search : 1-dim Range Trees 2.2-dimensional.
Parallel Prefix Computation Advanced Algorithms & Data Structures Lecture Theme 14 Prof. Dr. Th. Ottmann Summer Semester 2006.
The Lower Envelope: The Pointwise Minimum of a Set of Functions Computational Geometry, WS 2006/07 Lecture 4 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen,
Orthogonal Range Searching-1Computational Geometry Prof. Dr. Th. Ottmann 1 Orthogonal Range Searching 1.Linear Range Search : 1-dim Range Trees 2.2-dimensional.
Lecture 5: Orthogonal Range Searching Computational Geometry Prof. Dr. Th. Ottmann 1 Orthogonal Range Searching 1.Linear Range Search : 1-dim Range Trees.
Special Cases of the Hidden Line Elimination Problem Computational Geometry, WS 2007/08 Lecture 16 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen,
Voronoi Diagrams Computational Geometry, WS 2006/07 Lecture 10 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
Duality and Arrangements Computational Geometry, WS 2007/08 Lecture 6 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
Orthogonal Range Searching Computational Geometry, WS 2006/07 Lecture 13 – Part III Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für.
Persistent Data Structures Computational Geometry, WS 2007/08 Lecture 12 Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen, Institut.
Linear Programming Computational Geometry, WS 2007/08 Lecture 7 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
I/O-Algorithms Lars Arge University of Aarhus March 1, 2005.
I/O-Algorithms Lars Arge Spring 2009 March 3, 2009.
1 Geometric Solutions for the IP-Lookup and Packet Classification Problem (Lecture 12: The IP-LookUp & Packet Classification Problem, Part II) Advanced.
Geometric Data Structures Computational Geometry, WS 2007/08 Lecture 13 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Hidden-Line Elimination Computational Geometry, WS 2006/07 Lecture 14 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
Linear Programming Computational Geometry, WS 2007/08 Lecture 7, Part II Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
Closest Pair of Points Computational Geometry, WS 2006/07 Lecture 9, Part II Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen,
Linear Programming Computational Geometry, WS 2006/07 Lecture 5, Part III Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
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 6: Point Location Computational Geometry Prof. Dr. Th. Ottmann 1 Point Location 1.Trapezoidal decomposition. 2.A search structure. 3.Randomized,
IP-Lookup and Packet Classification Computational Geometry, WS 2007/08 Lecture 14 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für.
Lecture 11 : More Geometric Data Structures Computational Geometry Prof. Dr. Th. Ottmann 1 Geometric Data Structures 1.Rectangle Intersection 2.Segment.
Polygon Triangulation Computational Geometry, WS 2006/07 Lecture 8, Part 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Linear Programming Computational Geometry, WS 2006/07 Lecture 5, Part II Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Line Segment Intersection Computational Geometry, WS 2006/07 Lecture 3 – Part II Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
O RTHOGONAL R ANGE S EARCHING الهه اسلامی فروردین 92, 1.
Spatial Indexing I Point Access Methods. Spatial Indexing Point Access Methods (PAMs) vs Spatial Access Methods (SAMs) PAM: index only point data Hierarchical.
Duality and Arrangements Computational Geometry, WS 2006/07 Lecture 7 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
Line Segment Intersection Computational Geometry, WS 2006/07 Lecture 3 – Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Fractional Cascading and Its Applications G. S. Lueker. A data structure for orthogonal range queries. In Proc. 19 th annu. IEEE Sympos. Found. Comput.
Spatial Indexing I Point Access Methods. Spatial Indexing Point Access Methods (PAMs) vs Spatial Access Methods (SAMs) PAM: index only point data Hierarchical.
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.
Data Structures for Computer Graphics Point Based Representations and Data Structures Lectured by Vlastimil Havran.
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.
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.
B-trees and kd-trees Piotr Indyk (slides partially by Lars Arge from Duke U)
Mehdi Mohammadi March Western Michigan University Department of Computer Science CS Advanced Data Structure.
2IL50 Data Structures Fall 2015 Lecture 9: Range Searching.
Orthogonal Range Search
Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930.
Multi-dimensional Search Trees CS302 Data Structures Modified from Dr George Bebis.
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.
May 2012Range Search Algorithms1 Shmuel Wimer Bar Ilan Univ. Eng. Faculty Technion, EE Faculty.
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]
Shmuel Wimer Bar Ilan Univ., School of Engineering
CMPS 3130/6130 Computational Geometry Spring 2017
CMPS 3130/6130 Computational Geometry Spring 2017
Presentation transcript:

Computational Geometry, WS 2007/08 Lecture 15 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften Albert-Ludwigs-Universität Freiburg Orthogonal Range Searching

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann2 Motivation: OLAP Linear Range Search : 1-dim Range Trees 2-dimensional Range Search : kd-trees 2-dimensional Range Search : 2-dim Range Trees Range Search in Higher Dimensions Orthogonal Range Searching

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann3 Salary Children Age Input: Set of data points in d-space, orthogonal (iso-oriented) query range R Output: All points contained in R Range search

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann4 Supports „decision support“ in companies Reporting, analysis, planning etc. Data Warehousing Interactive data exploration –„Roll-up“ and „Drill-down“along hierarchies –Hypothetical Scenarios („what-if-queries“) –Aggregation of values is a central operation –Real-time performance OLAP: On-Line Analytical Processing

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann5 Typical query: „What are the sales values obtained by team A during the 4th quarter in area 7“ Example

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann6 Hierarchies in dimensions

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann7 Data Cube Centrale operation: Aggregation of values along hierarches and dimensions, resp. (Group-by,…) Aggregat-operation: –sum, average, max/min, count –top-k, dominance, iceberg, skyline

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann8 OLAP – Implementations Multidimensional OLAP (MOLAP) –Special multidimensional datenstructures Cube in main memory („in-memory OLAP“) –Online-aggregation Cheap updates, expensive queries Write-back-facility, implies„what-if“-analysis –Applix TM1, Jedox Palo Other Variants: ROLAP, Hybrid Solutions

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann9 Array-based approach Naive Approach: –Range queries in time O(n d ), Updates in time O(1) Prefix sum [Ho et al. 1997]: Store aggregated values insteadof base values –Range queries in time O(1), Updates in time O(n d ) Relative prefix sum [Geffner et al. 1999]: Partition arrays into pairwise disjoint chunks –Range queries in time O(n d/2 ), Updates in time O(n d/2 ) –Tradeoff can be adjusted (by appropriate choice of chunk size)

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann10 1-dimensional range search Input: A linearly ordered set S of n (integer) values (points on the line). A range [x l, x r ] Output: Report all points x with x l ≤ x ≤ x r In general, the set S is dynamic! (insertions, deletions of points)

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann11 Binary leaf search tree

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann12 Range search

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann13 Finding the split node for query range [x, x´] FindSplitNode (T, x, x´) v = root (T) while not leaf(v) && (x´  v.x || x > v.x) if (x´  v.x) then v = left(v) else v = right(v) return v Running time : O(log n) Note : Only O(log n) subtrees fall into the query range. 1-Dimensional range query

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann Split node Query range: [22, 77] Example – Binary Search Tree

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann15 1DRangeQuery (T, [x, x´]) v split = FindSplitNode (T, x, x´) if ( leaf (v split ) && v split in R=[x, x´]) then write v split ; return; v = left-child(v split ); while (not leaf (v)) if (x  v.x ) then write Subtree (right-child(v)); v= left-child(v); else v = right-child(v) if (v in R) write v ; v = right-child(v split )... rchild(v) s v p xx´ Algorithm 1-d-range-search

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann16 A 1-dim range query in a set of n points can be answered in time O(log n + k) using a 1-d-range tree, where k is the number of reported points which fall into the given range. Proof : FindSplitNode: O(log n) Leaf search: O(log n) The number of green nodes is O(k), since number of internal nodes is O(k)  O((log n)+k) total time. Theorem

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann17 Let P be a set of n points in 1-dimensional space. The set P can be stored in a balanced binary search tree, which uses O(n) storage and has O(n log n) construction time, such that the points in a query range can be reported in time O(k + log n), where k is the number of reported points. Summary

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann18 Assumption : No two points have the same x- or y-coordinates 2 – dimensional range search

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann19 1 p ,2,3,4,56,7,8,9,10 P1P1 P2P2 Construction of kd-trees (k = 2)

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann Construction of kd-trees (k = 2)

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann21 BuildTree (P, depth) if (|P| = 1) return leaf(P); if (depth even) split P into P 1,P 2 through vertical median else split P into P 1,P 2 through horizontal median v 1 = BuildTree (P 1, depth + 1) v 2 = BuildTree (P 2, depth + 1) return (v 1, median, v 2 ) Algorithm for building 2d-trees

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann22 Theorem: The algorithm for constructing a 2d-tree uses O(n) storage and can be carried out in time O(n log n) Proof: Space: 2d-tree is a binary tree with n leaves. Time: O(1), if n =1 T(n) = O(n) + 2T(n/2), if n > 1 T(n)  cn + 2T(n/2)  cn + 2(cn/2 + 2T(n/4))  = O(n log n) Analysis

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann below left right above Regions: Region(5) is left of 1 and above 2 Incremental : Region(left(v)) = left(v)  Region(v) Nodes represent regions

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann SearchTree(v,R) if (leaf(v) && v in R) then write v; return if (Region(left(v)) in R ) then write Subtree(left(v)), return if (Region(left(v))  R <>  ) then SearchTree(left(v), R) if (Region(right(v)) in R) then write Subtree(right(v)),return if (Region(right(v))  R <>  ) then SearchTree(right(v),R) Algorithm search in a 2d-tree

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann25 Lemma : A query with an axis-parallel rectangle in a 2d-tree storing n points can be performed in O(√n + k) time, where k is the number of reported points. Proof : B = # of blue nodes, G = # of green nodes G(n) = O(k). B(n)  # of vertical intersection regions V + # of horizontal intersection regions H Line l intersects either the region to left of root(T) or to the right. This gives the following recursion: V(n) = O(1), if n = 1 = 2 + 2V(n/4), if n > 1 V(n) = log 4 n =  n = O(  n) Analysis algorithm search in 2d-tree

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann26 V # of regions in a 2d-tree with n points, which are intersected by a vertical straight line. V(1)= 1 V(n)= 2+ 2V(n/4) Number of intersected regions

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann27 A 2d-tree for a set P of n points in the plane uses O(n) storage and can be built in O(n log n) time. A rectangular range query on the 2d-tree takes time, where k is number of reported points. Summary

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann28 Two Dimensional Range Search y x Assumption: no two points have the same x or y coordinates 2-dim Range Trees

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann29 V V split P(v) = set of points of the subtree with root v. Canonical subset of a node

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann30 X Y Associated tree

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann31 1.The main tree (1st level tree) is a balanced binary search tree T built on the x – coordiante of the points in P. 2.For any internal or leaf node v in T, the canonical subset P(v) is stored in a balanced binary search tree T assoc (v) on the y – coordinate of the points. The node v stores a pointer to the root of T assoc (v) which is called the associated structure of v. 2-dim range tree for a set P

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann32 V p T (x – sorted) T´(v) (y – sorted) For all nodes in T store entire point information. All nodes y - presorted Build2DRangeTree(P) 1.Construct associated tree T´ for the points in P (based on y-coordinates) 2.If (  P  = 1) then return leaf(P), T´(leaf(P)) else split P into P1, P2 via median x v1 = Build2DRangeTree(P1) v2 = Build2DRangeTree(P2) create node v, store x in v, left-child(v) =v1,right-child(v) = v2 associate T´ with v Constructing range trees

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann33 Statement : A range tree on a set of n points in the plane requires O(n log n) storage. Proof : A point p in P is stored only in the associated structure of nodes on the path in T towards the leaf containing p. Hence, for all nodes at a given depth of T, the point p is stored in exactly one associated structure. We know that 1 – dimensional range trees use linear storage, so associated structures of all nodes at any depth of T together use O(n) storage. The depth of T is O(log n). Hence total amount of storage required is O(n log n). Lemma

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann34 Lemma Statement : A range tree on a set of n points in the plane requires O(n log n) storage. Proof : A point p in P is stored only in the associated structure of nodes on the path in T towards the leaf containing p. Hence, for all nodes at a given depth of T, the point p is stored in exactly one associated structure. We know that 1 – dimensional range trees use linear storage, so associated structures of all nodes at any depth of T together use O(n) storage. The depth of T is O(log n). Hence total amount of storage required is O(n log n).

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann35 Algorithm 2DRangeQuery(T,[x : x´]  [y : y´]) v split = FindSplitNode(T,x,x´) if (leaf(v split ) & v split is in R) then report v, return elsev = left-child(v split ) while not (leaf(v)) do if (x  x v ) then 1DRangeQuery(T assoc ( right-child(v)),[ y : y’]) v = left-child(v) else v = right-child(v) if (v is in R) then report v v = right-child(v split )... Similarly … Search in 2-dim-range trees

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann36 Lemma: A query with an axis – parallel rectangle in a range tree storing n points takes O(log²n + k) time, where k is the number of reported points. Proof : At each node v in the main tree T we spend constant time to decide where the search path continues and evt. call 1DRangeQuery. The time we spend in this recursive call is O(log n + k v ) where is k v the number of points reported in this call. Hence the total time we spend is Furthermore the search paths of x and x´in the main tree T have length O(log n). Hence we have Analysis

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann37 Time required for construction: T 2 (n) = O( n log n) T d (n) = O( n log n) + O( log n) * T d-1 (n)  T d (n) = O( n log d-1 n) Time required for range query (without time to report points): Q 2 (n) = O( log 2 n) Q d (n) = O( log n) + O( log n) *Q d-1 (n)  Q d (n) = O( log d n + k) Higher-dimensional range trees

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann38 Given : Two ordered arrays A1 and A2. key(A2)  key(A1) query[x, x´] Search : All elements e in A1 and A2 with x  key(e)  x´. Idea : pointers between A1 and A2 Example query : [20 : 65] Run time : O(log n + k) Run time : O(1 + k) Search in Subsets

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann39 Idea : P1  P, P2  P Fractional Cascading

Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann x-value y-value Theorem : query time can be reduced to O(log n + k). Proof : In d dimension a saving of one log n factor is possible. Fractional Cascading