Closest Pair of Points. Kleinberg and Tardos Section 5.4



Similar documents
5.4 Closest Pair of Points

CSE 421 Algorithms: Divide and Conquer

Closest Pair Problem

28 Closest-Point Problems

Computational Geometry. Lecture 1: Introduction and Convex Hulls

Analysis of Binary Search algorithm and Selection Sort algorithm

Well-Separated Pair Decomposition for the Unit-disk Graph Metric and its Applications

Many algorithms, particularly divide and conquer algorithms, have time complexities which are naturally

Scheduling Single Machine Scheduling. Tim Nieberg

CSC148 Lecture 8. Algorithm Analysis Binary Search Sorting

EE602 Algorithms GEOMETRIC INTERSECTION CHAPTER 27

Solving Geometric Problems with the Rotating Calipers *

Medical Information Management & Mining. You Chen Jan,15, 2013 You.chen@vanderbilt.edu

Scan-Line Fill. Scan-Line Algorithm. Sort by scan line Fill each span vertex order generated by vertex list

1. Then f has a relative maximum at x = c if f(c) f(x) for all values of x in some

Algorithm Analysis [2]: if-else statements, recursive algorithms. COSC 2011, Winter 2004, Section N Instructor: N. Vlajic

Near Optimal Solutions

The Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)!

Geometric Algorithms. primitive operations convex hull closest pair voronoi diagram. References: Algorithms in C (2nd edition), Chapters 24-25

DATA MINING CLUSTER ANALYSIS: BASIC CONCEPTS

INTERSECTION OF LINE-SEGMENTS

CSC2420 Spring 2015: Lecture 3

Definition 8.1 Two inequalities are equivalent if they have the same solution set. Add or Subtract the same value on both sides of the inequality.

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.



Binary search algorithm

P13 Route Plan. E216 Distribution &Transportation

Applied Algorithm Design Lecture 5

Vector storage and access; algorithms in GIS. This is lecture 6

4 The Rhumb Line and the Great Circle in Navigation

Computer Science 210: Data Structures. Searching

8. Linear least-squares

Session 7 Bivariate Data and Analysis

Sorting Algorithms. Nelson Padua-Perez Bill Pugh. Department of Computer Science University of Maryland, College Park

Euclidean Minimum Spanning Trees Based on Well Separated Pair Decompositions Chaojun Li. Advised by: Dave Mount. May 22, 2014

ARTIFICIAL INTELLIGENCE (CSCU9YE) LECTURE 6: MACHINE LEARNING 2: UNSUPERVISED LEARNING (CLUSTERING)

Clustering. Danilo Croce Web Mining & Retrieval a.a. 2015/201 16/03/2016

Reflection and Refraction

Clustering UE 141 Spring 2013

3 An Illustrative Example

Lecture 1: Course overview, circuits, and formulas

Clustering. Adrian Groza. Department of Computer Science Technical University of Cluj-Napoca

Data Mining Cluster Analysis: Basic Concepts and Algorithms. Lecture Notes for Chapter 8. Introduction to Data Mining

Analysis of Algorithms I: Optimal Binary Search Trees

Data Mining Cluster Analysis: Basic Concepts and Algorithms. Clustering Algorithms. Lecture Notes for Chapter 8. Introduction to Data Mining

Chapter 13: Query Processing. Basic Steps in Query Processing

MA 408 Computer Lab Two The Poincaré Disk Model of Hyperbolic Geometry. Figure 1: Lines in the Poincaré Disk Model

Efficiently Identifying Inclusion Dependencies in RDBMS

Chapter Load Balancing. Approximation Algorithms. Load Balancing. Load Balancing on 2 Machines. Load Balancing: Greedy Scheduling

Earth, Moon, and Sun Study Guide. (Test Date: )

MACHINE LEARNING IN HIGH ENERGY PHYSICS

Linear Threshold Units

Recognition. Sanja Fidler CSC420: Intro to Image Understanding 1 / 28

8 9 +

11. APPROXIMATION ALGORITHMS

>

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

Shortest Path Algorithms

Environmental Remote Sensing GEOG 2021

Integer Programming: Algorithms - 3

IB Maths SL Sequence and Series Practice Problems Mr. W Name

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

4.1 Introduction - Online Learning Model

Special Situations in the Simplex Algorithm

Warshall s Algorithm: Transitive Closure

8.1 Min Degree Spanning Tree

Unsupervised Learning and Data Mining. Unsupervised Learning and Data Mining. Clustering. Supervised Learning. Supervised Learning

Representing Vector Fields Using Field Line Diagrams

Going Big in Data Dimensionality:

Bargaining Solutions in a Social Network

CIS 700: algorithms for Big Data

3. Evaluate the objective function at each vertex. Put the vertices into a table: Vertex P=3x+2y (0, 0) 0 min (0, 5) 10 (15, 0) 45 (12, 2) 40 Max

COMP3420: Advanced Databases and Data Mining. Classification and prediction: Introduction and Decision Tree Induction

External Sorting. Chapter 13. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1

Systems of Linear Equations

Lecture 6: Binary Search Trees CSCI Algorithms I. Andrew Rosenberg

x x y y Then, my slope is =. Notice, if we use the slope formula, we ll get the same thing: m =

Lecture 4 Online and streaming algorithms for clustering

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]


Chapter 6 - Condor finder

Algorithms and Data Structures

csci 210: Data Structures Recursion

DICOM Correction Item

Data Mining Clustering (2) Sheets are based on the those provided by Tan, Steinbach, and Kumar. Introduction to Data Mining

Sample Questions Csci 1112 A. Bellaachia

External Sorting. Why Sort? 2-Way Sort: Requires 3 Buffers. Chapter 13

1. Write the number of the left-hand item next to the item on the right that corresponds to it.

Similarity Search in a Very Large Scale Using Hadoop and HBase

Cpt S 223. School of EECS, WSU

DATA ANALYSIS II. Matrix Algorithms

Shortcut sets for plane Euclidean networks (Extended abstract) 1

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

The number of marks is given in brackets [ ] at the end of each question or part question. The total number of marks for this paper is 72.

MIDAS: Multi-Attribute Indexing for Distributed Architecture Systems

α = u v. In other words, Orthogonal Projection

root node level: internal node edge leaf node Data Structures & Algorithms McQuain

Fraction Tools. Martin Kindt & Truus Dekker n

1 Review of Least Squares Solutions to Overdetermined Systems

Transcription:

Closest Pair of Points Kleinberg and Tardos Section 5.4

Closest Pair of Points Closest pair. Given n points in the plane, find a pair with smallest Euclidean distance between them. Fundamental geometric problem. Graphics, computer vision, geographic information systems, molecular modeling, air traffic control. Simple solution? 2

Closest Pair of Points Closest pair. Given n points in the plane, find a pair with smallest Euclidean distance between them. Fundamental geometric problem. Graphics, computer vision, geographic information systems, molecular modeling, air traffic control. Brute force solution. Compare all pairs of points: O(n 2 ). 1-D version? 3

1D, 2D versions 1D: Sort the points: O(n logn) Walk through the sorted list and find the min dist pair 2D: Does it extend to 2D? sort p-s by x: find min pair or sort p-s by y: find min pair what can we do with those?

Divide and Conquer Strategy Divide points into left half Q and right half R Find closest pairs in Q and R Merge the solutions What's the problem? Q R

Q R A point in Q may be closer to a point in R than the min pair in Q and the min pair in R

Combining the solutions Need to take point pairs between Q and R into account. We need to do this in O(n) time to keep complexity at O(n logn)

Closest Pair of Points Algorithm. Divide: draw vertical line L so that roughly ½n points on each side. To half our regions efficiently we sort the points once by x coordinate ( O(n logn) ). Then we split (O(1)) the problem P in two, Q (left half) and R (right half). We also sort the points by y (later) L Q R 8

Closest Pair of Points Algorithm. Divide: draw vertical line L so that roughly ½n points on each side. Recur: find closest pair in each side recursively. L 21 12 Q R

Closest Pair of Points Algorithm. Divide: draw vertical line L so that roughly ½n points on each side. Recur: find closest pair in each side recursively. Combine: find closest pair with one point in each side. Return best of 3 solutions. seems like Θ(n 2 ) or can we narrow the point pairs we look at? L 8 21 12 Q R

Combining the solutions Given Qs min pair (q 1,q 2 ) and Rs min pair (r 1,r 2 ), δ=min(dist(q 1,q 2 ), dist(r 1,r 2 )). What can we do with δ? Can δ narrow the number of points in Q and R that we need to compare? YES! Find closest pair with one point in each side, assuming distance < δ. L 21 12 δ = min(12, 21)

Combining the solutions Find closest pair with one point in each side, assuming distance < δ. Observation: only need to consider points within δ of line L. L 21 12 δ = min(12, 21) δ 12

Combining the solutions Find closest pair with one point in each side, assuming distance < δ. Observation: only need to consider points within δ of line L. But we can t afford to look at all pairs of points! L 21 12 δ = min(12, 21) δ 13

Combining the solutions Find closest pair with one point in each side, assuming distance < δ. Observation: only need to consider points within δ of line L. Select sorted by y coordinate points in 2δ-strip. But how many points à pairs can there be in the strip? Points: O(n) à Pairs O(n 2 ) 7 L 6 4 5 21 12 3 δ = min(12, 21) 2 1 δ 14

Combining the solutions Find closest pair with one point in each side, assuming distance < δ. Observation: only need to consider points within δ of line L. Select sorted by y coordinate points in 2δ-strip. For each point in the strip only check distances of those within 7 positions in sorted list! 7 L 6 4 5 21 12 3 δ = min(12, 21) 2 1 δ 15

Why is checking 7 next points sufficient?. δ/2 δ/2 Consider 2 rows of four δ/2 x δ/2 boxes inside strip, starting at y coordinate of the point. At most one point can live in each box! Because max distance between two points in a box = 2 2 δ < δ L-δ L L+δ

Why is checking 7 next points sufficient?. δ/2 δ/2 L-δ L L+δ Consider 2 rows of four δ/2 x δ/2 boxes inside strip. At most one point can live in each box! So if point is more than 7 indices away, its distance must be greater than δ. So combining solutions can be done in linear time!

Do we need to check 7 points? NO!! As soon as a Y coordinate of next point is > δ away, we can stop. BTW, the book uses a different argument to come up with 15 points. 18

Closest Pair Algorithm Closest-Pair(p 1,, p n ) { compute line L such that half the points are on one side and half on the other side. δ 1 = Closest-Pair(left half) δ 2 = Closest-Pair(right half) δ = min(δ 1, δ 2 ) scan points in δ strip by their y-order and compare distance between each point next neighbors until distance > δ. If any of these distances is less than δ, update δ. O(n) 2T(n / 2) O(n) } return δ. Running time: O(n log n) 19