Closest Pair of Points Computational Geometry, WS 2006/07 Lecture 9, Part II Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen,

Slides:



Advertisements
Similar presentations
Order-k Voronoi Diagram in the Plane
Advertisements

Two Segments Intersect?
Line Segment Intersection Computational Geometry, WS 2007/08 Lecture 3 – Supplementary Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut.
Comments We consider in this topic a large class of related problems that deal with proximity of points in the plane. We will: 1.Define some proximity.
Divide-and-conquer: closest pair (Chap.33) Given a set of points, find the closest pair (measured in Euclidean distance) Brute-force method: O(n 2 ). Divide-and-conquer.
9/12/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries II Carola Wenk.
Lecture 4 Divide and Conquer for Nearest Neighbor Problem
Closest Pair Given a set S = {p1, p2,..., pn} of n points in the plane find the two points of S whose distance is the smallest. Images in this presentation.
The Divide-and-Conquer Strategy
Convex Hulls Computational Geometry, WS 2007/08 Lecture 2 – Supplementary Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2013 Lecture 11.
Reminder: Closest-Pair Problem Given a collection P of n points in  × , obtain the two points p1 and p2 such that their distance is less or equal that.
1 Divide-and-Conquer Divide-and-conquer. n Break up problem into several parts. n Solve each part recursively. n Combine solutions to sub-problems into.
Convex Hull Problem Presented By Erion Lin. Outline Convex Hull Problem Voronoi Diagram Fermat Point.
1 Closest Points A famous algorithmic problem... Given a set of points in the plane (cities in the U.S., transistors on a circuit board, computers on a.
9/5/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Plane Sweep Algorithms and Segment Intersection Carola Wenk.
November 4, Algorithms and Data Structures Lecture XIV Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Convex Hulls Today: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness,
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.
The Half-Edge Data Structure Computational Geometry, WS 2007/08 Lecture 3, Part III Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen,
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.
The Half-Edge Data Structure
Delaunay Triangulation Computational Geometry, WS 2006/07 Lecture 11 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
1 Lecture 8: Voronoi Diagram Computational Geometry Prof. Dr. Th. Ottmann Voronoi Diagrams Definition Characteristics Size and Storage Construction Use.
Line Segment Intersection Computational Geometry, WS 2007/08 Lecture 3 – Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
The Lower Envelope: The Pointwise Minimum of a Set of Functions Computational Geometry, WS 2006/07 Lecture 4 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen,
Algorithm Design Strategy Divide and Conquer. More examples of Divide and Conquer  Review of Divide & Conquer Concept  More examples  Finding closest.
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.
Introduction to Computational Geometry Computational Geometry, WS 2007/08 Lecture 1 – Part II Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut.
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.
Geometric Data Structures Computational Geometry, WS 2007/08 Lecture 13 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Lecture 4: Divide and Conquer III: Other Applications and Examples Shang-Hua Teng.
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.
Polygon Triangulation Computational Geometry, WS 2007/08 Lecture 9 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
Linear Programming Computational Geometry, WS 2006/07 Lecture 5, Part III Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Lecture 6 Divide and Conquer for Nearest Neighbor Problem Shang-Hua Teng.
Orthogonal Range Searching Computational Geometry, WS 2006/07 Lecture 13 - Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für.
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.
Art Gallery Theorem Computational Geometry, WS 2006/07 Lecture 8, Part 1 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
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.
1 Geometric Intersection Determining if there are intersections between graphical objects Finding all intersecting pairs Brute Force Algorithm Plane Sweep.
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2013 Lecture 12.
1 Closest Pair of Points (from “Algorithm Design” by J.Kleinberg and E.Tardos) Closest pair. Given n points in the plane, find a pair with smallest Euclidean.
1 Chapter 5 Divide and Conquer Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 Chapter 5 Divide and Conquer Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Divide and Conquer Applications Sanghyun Park Fall 2002 CSE, POSTECH.
Line Segment Intersection Computational Geometry, WS 2006/07 Lecture 3 – Part III Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für.
CMPS 3130/6130 Computational Geometry Spring 2015
Lecture 5 Today, how to solve recurrences We learned “guess and proved by induction” We also learned “substitution” method Today, we learn the “master.
1/20/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Plane Sweep Algorithms I Carola Wenk.
Advanced Algorithms Analysis and Design
Chapter 5 Divide and Conquer
An Introduction to Computational Geometry
CMPS 3130/6130 Computational Geometry Spring 2017
Divide and Conquer / Closest Pair of Points Yin Tat Lee
Chapter 5 Divide and Conquer
Divide and Conquer / Closest Pair of Points Yin Tat Lee
CSCI 256 Data Structures and Algorithm Analysis Lecture 12
Given a list of n  8 integers, what is the runtime bound on the optimal algorithm that sorts the first eight? O(1) O(log n) O(n) O(n log n) O(n2)
Presentation transcript:

Closest Pair of Points Computational Geometry, WS 2006/07 Lecture 9, Part II Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften Albert-Ludwigs-Universität Freiburg

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann2 Overview Motivation Closest Pair algorithms –Improving the naïve runtime –Divide and Conquer –Scan Line Analyses

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann3 Geometry and Air Traffic Control » Avoid collisions at all costs. » Start by finding the two aeroplanes closest to each other, at specific elevations. » During peak times over 5000 planes, per hour, around Frankfurt airspace.

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann4 Geometry and Astronomy » Find the two nearest objects in space.

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann5 Search Quickly… and Why? » Find the two nearest objects in space.

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann6 Problem Description Input: A set S of n points in the plane. Output: The pair of points with the shortest Euclidean distance between them. Other applications in fundamental geometric primitive: –Graphics, computer vision, geographic information systems, molecular modeling –Special case of nearest neighbour, Euclidean MST, Voronoi

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann7 Closest Pair of Points Naïve method: Brute force. –Check all pair of points p and q with Θ(n 2 ) comparisons. 1D version –Simple if all points are on a single line. –Run time O(n log n) Key to reducing quadratic runtime of the naïve method: Simply don´t visit each point n times.

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann8 Algorithm: DAC – Divide Sort S in ascending order of x-coordinates. Find the median line L, so that we have ½ n points in S L and ½ n points S R. SLSL SRSR

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann9 Algorithm: DAC – Conquer Recursively, find the closest pair in S L and S R. SLSL SRSR

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann10 Algorithm: DAC – Merge (Strip-Margins) Assuming that distance <  S = min(  SL,  SR ). Observation: Only need to consider the points within  S of line L. SLSL SRSR SS  S = min(12,21)

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann11 Handling Merge Sort points in 2  S -strip in ascending y-coordinate order. (First observation) Only check those points within 11 positions in sorted list. SLSL SRSR SS  S = min(12,21)

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann12 Comparing Efficiently Definition: Let s i be the point in the 2  S -strip with the i th smallest coordinate. Claim: If |i - j|  12, then the distance between s i and s j is at least  S. Proof: The points s i and s j cannot lie in same ½  S -by- ½  S box. s i and s j are at least 2 rows apart, and have distance  2(½  S ). Fact: The above still holds if we replace 12 with 7. SS SS

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann13 Closest Pair: DAC Algorithm Algorithm: Closest-Pair( S = {p 1, …, p n } ) Sort all n points in ascending x-coordinate order Compute the median line L, and divide S into S L and S R Set  SL  Closest-Pair(S L ) Set  SR  Closest-Pair(S R ) Set  S  min(  SL,  SR ) Delete all points further than  S  from separation line L Sort remaining points in ascending y-coordinate order Scan points in y-order and compare distance between each point and next 7 neighbours. Update  S if new shorter distance is found. Return  S

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann14 Closest Pair: DAC Analysis Run time: T(N)  2T(N/2) + O(N log N)  T(N) = O(N log 2 N) Can we achieve a better run time? Yes. Don’t sort points in strip from scratch each time. Each recursive step returns two lists: all points sorted by y- coordinate, and all points sorted by x-coordinate. Sort by merging two pre-sorted list. T(N)  2T(N/2) + O(N)  T(N) = O(N log N) Space: O(n)

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann15 Algorithm: Scan-Line Sort S in ascending order of x-coordinates. Place sorted points p 1, …, p n in the event-queue. Initialise   distance(p 1, p 2 ). Start scanning from p 3. » Event-points? » Status structure?

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann16 The Status-Structure Maintain the status-structure (  -slab): –Insert the new event-point p i. –Remove all points that are greater than  distance to the left of the current event-point p i. –All points in the status structure are maintained in ascending y- coordinate order.

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann17 The Status-Structure Maintain the status-structure (  -slab): –Insert the new event-point p i. –Remove all points that are greater than  distance to the left of the current event-point p i. –All points in the status structure are maintained in ascending y- coordinate order. –Perform the ‘Efficient Comparison’, as described earlier, BUT only between the new event point p i and at most 7 other nearest points to p i. –Update  if a shorter distance is found.

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann18 Closest Pair: Scan-Line Analysis Invariant: Whenever an event-point p i has been handled, then  is the minimum distance between any pair of points encountered from p 1 up to p i. Run time: O(n log n) Space: O(n)

Computational Geometry, WS 2006/07 Prof. Dr. Thomas Ottmann19 Related Problems Nearest neighbour query: –Given a set S of n points, and a query point q, determine which s  S is closest to q. –Brute force: O(n) –Goal: O(n log n) pre-processing, O(log n) per query. Voronoi region, VR(S): –A set of points closest to a given point. Voronoi diagram, VD(S): –Planar subdivision deliniating Voronoi regions. Delaunay Triangulation (the dual of VD(S)).