# NN - CSE 4101/5101 Prof. Andy Mirzaian Nearest Neighbors &...

This preview shows pages 1–7. Sign up to view the full content.

CSE 4101/5101 Nearest Neighbors Closest Pair Prof. Andy Mirzaian

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
References: Lecture Note 8 [LN8] [CLRS] chapter 33 Applications: q Proximity clustering q Pattern Recognition q Related to: Euclidean Minimum Spanning Tree, Relative Neighborhood Graph, Delaunay Triangulation 2
The Closest Pair of Points Input: A set P = {p1 , p2 , … , pn } of n points in the plane. .n. Output: The closest pair of points in P, i.e., the pair (pi, pj) in P, i  j , with minimum Euclidean distance d(pi, pj) = ((xi - xj)2 +(yi - yj)2 ) ½ . In 1 dimension: The Min-Gap Problem . Known lower bound on time complexity: (n log n). Discussed later. Matching upper bound (by sorting first): O(n log n). y x In 2 dimensions it is at least as hard. Brute Force: Try every pair. That takes Θ (n2) time. ………………………………………… P.T.O. 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
P n points L n/2 points R n/2 points The closest pair of points are either: a) both in the left half L, or [recursive call on L] b) both in the right half R, or [recursive call on R] c) one is in L and the other in R. x-median CP(P): CP(L) CP(R) y x 4
Procedure CP (P) Pre-Condition: P is a x-sorted finite set of points Post-Condition: Output is the closest pair of points in P 3.Base: if |P| < 10 then return answer by brute-force in Θ (1) time 4.Divide: Partition P at its x-median value into sets L and R, |L| |R| |P|/2 5.Conquer: SolL  CP (L); SolR  CP (R) 6.Combine: Sol  MERGE (SolL , SolR ) 7.Output: return Sol end Algorithm ClosestPair (P) Pre-Condition: P is a finite set of points in the plane Post-Condition: Output is the closest pair of points in P 1. Pre-Sort points in P on their x-coordinates (lexicographically next on y) 2. return CP(P) end T(n) = 2T(n/2) + Θ(ν29 Τ(ν29 = Θ(ν λογ ν29 τιμε. Our aim 5

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Procedure CP (P) Pre-Condition: P is a x-sorted finite set of points Post-Condition: Output is the closest pair of points in P 3.Base: if |P| < 10 then return answer by brute-force in Θ (1) time 4.Divide: Partition P at its x-median value into sets L and R, |L| |R| |P|/2 5.Conquer: SolL  CP (L); SolR  CP (R) 6.Combine: Sol  MERGE (SolL , SolR ) 7.Output: return Sol end Algorithm ClosestPair (P) Pre-Condition: P is a finite set of points in the plane Post-Condition: Output is the closest pair of points in P 1. Pre-Sort points in P on their x-coordinates (lexicographically next on y) 2. return CP(P) end Post-Cond of MERGE must imply Post-Cond of CP(P). On the other hand,
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/13/2012 for the course CSE 4101 taught by Professor Mirzaian during the Winter '12 term at York University.

### Page1 / 27

NN - CSE 4101/5101 Prof. Andy Mirzaian Nearest Neighbors &...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online