- lecture2
- BIG-O
- Lecture 03
- Uncapacitated Multiple Allocation
- 02-asymp
- lecture1[1]
- miaa360lessonstudygrade5-1
- 1 Basic Concepts
- CST Melissa
- X06Growth.ppt
- Questions on Artificial Intelligence
- Almost Optimal Set Covers in Finite VC-Dimension
- Bigo
- practice-sheet-1.pdf
- Analysis of Algorithms
- best lp
- Electronic, Signed Modalities for Telephony
- 6 linear relations blm extra practice sheets answer keys
- parent overview es3 graphing
- Aula3_lab
- A Greedy Branch-And-Bound Inclusion-Exclusion Algorithm for Calculating the Exact Multi-State Network Reliability
- maximizing the profit of a business
- Covering Graphs using Trees and Stars
- 14 (1).pdf
- 6-Moments Couples and Force Couple Systems_Partb.ppt
- Cantelever Beam PBEAML
- lesson plan coordinate planes
- maximizing the profit of a business
- maximizing the profit of a business
- B61393E_2_02 - Connection Manual
- Sapiens: A Brief History of Humankind
- The Unwinding: An Inner History of the New America
- Yes Please
- Dispatches from Pluto: Lost and Found in the Mississippi Delta
- Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
- The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution
- John Adams
- Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
- A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
- Grand Pursuit: The Story of Economic Genius
- This Changes Everything: Capitalism vs. The Climate
- The Emperor of All Maladies: A Biography of Cancer
- The Prize: The Epic Quest for Oil, Money & Power
- Team of Rivals: The Political Genius of Abraham Lincoln
- The New Confessions of an Economic Hit Man
- The World Is Flat 3.0: A Brief History of the Twenty-first Century
- Rise of ISIS: A Threat We Can't Ignore
- Smart People Should Build Things: How to Restore Our Culture of Achievement, Build a Path for Entrepreneurs, and Create New Jobs in America
- The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
- How To Win Friends and Influence People
- Angela's Ashes: A Memoir
- Steve Jobs
- Bad Feminist: Essays
- The Light Between Oceans: A Novel
- Leaving Berlin: A Novel
- The Silver Linings Playbook: A Novel
- The Sympathizer: A Novel (Pulitzer Prize for Fiction)
- Extremely Loud and Incredibly Close: A Novel
- You Too Can Have a Body Like Mine: A Novel
- The Incarnations: A Novel
- Life of Pi
- The Love Affairs of Nathaniel P.: A Novel
- A Man Called Ove: A Novel
- Bel Canto
- The Master
- We Are Not Ourselves: A Novel
- The First Bad Man: A Novel
- The Rosie Project: A Novel
- The Blazing World: A Novel
- Brooklyn: A Novel
- The Flamethrowers: A Novel
- The Art of Racing in the Rain: A Novel
- Wolf Hall: A Novel
- The Wallcreeper
- Interpreter of Maladies
- Beautiful Ruins: A Novel
- The Kitchen House: A Novel
- The Perks of Being a Wallflower
- The Bonfire of the Vanities: A Novel
- Lovers at the Chameleon Club, Paris 1932: A Novel
- A Prayer for Owen Meany: A Novel
- The Cider House Rules
- Mislaid: A Novel

**Closest pair in a plane
**

Ashish Sharma Rengakrishnan Subramanian

November 28, 2001 Given the Cartesian coordinates of n points in a plane, this paper is concerned with finding the closest pair of points in a time in O (n log n).

Input

A set P of n points in the plane. P = {p (1), p (2), …., p(n)}, where p(i) = { x(i), y(i) }

Output

A pair of points that is closest in the input set.

Algorithm Introduction

The algorithm described here uses a divide and conquer approach to find out the closest pair of points in a plane. It takes an input array of points of the type described as input above. The distance between any two points in Cartesian geometry is defined as: Distance { (x1 ,y1 ), (x2 ,y2 ) } = Square root of ( (x1 – x2 )2 + (y1 – y2 )2 ). In this algorithm, we assume that the expression DISTANCE (i, j) defines the distance between p(i) and p(j) in the input array. The input can be viewed in the plane as shown below: y-axis

x-axis

Page 1 of 6

The closest pair is such that one point is in the left sub-plane and other point is in the right sub-plane The algorithm now keeps on dividing each sub-plane (PLeft and PRight ) and stops dividing until it finds a sub-plane with only two or three points in it. In such a case.Closest Pair Working We assume that the input array is sorted along the x coordinate of each element. This procedure is not Page 2 of 6 . The plane is now divided into two halves in such a way that: PLeft = { p(1). …. ……. The vertical line is placed exactly at the middle between the leftmost and the rightmost point in the input array. p(n) } There are three possibilities at this stage: a. for each j. p(2). which takes in input S. . which is exactly at (x0 + xn )/2. The algorithm proceeds by drawing a vertical line across the plane and dividing the plane into two halves. PLeft and PRight. the algorithm uses a procedure SHORTEST (S). The plane can now be viewed as: x-axis PLeft PRight . In this plane. The closest pair is in the right sub-plane c. x(j) ≤ x(j+1). p(n/2) } PRight = { p(n/2 + 1). a set of three or lesser points and returns a pair of points which is the closest pair in the set S. The closest pair is in the left sub-plane b. .

. Pclosest if (n ≤ 3) return SHORTEST (P) else PLeft ← { p(1). p(n) } Pleftmin ← findclosest (PLeft . Algorithm procedure findclosest ( P. p(2). PRight . Prightmin) return Pclosest for (every i in P1) for every j in P2 such that xi < xj + ∆ AND (yi +d > yj > yi – d ) if DISTANCE (i. Pleftmin.Closest Pair explained in detail in this paper. SHORTEST (S) always runs in constant time. So. p(n/2) } PRight ← { p(n/2 + 1). j) endfor endfor endprocedure Page 3 of 6 . …. P2) Pclosest ← MERGEPLANES (Pleftmin. n/2) endif endprocedure procedure MERGEPLANES (P1. ……. int n) { n is the number of elements in set P } Set: PLeft. j) < ∆ return (i. as the size of its input is always less than or equal to three. it does not affect the time complexity of the algorithm. n/2) Prightmin ← findclosest (PRight . Prightmin. P2) ∆ ← MINIMUM (P1. .

for a particular point in P1. ∆ 2∆ Page 4 of 6 .∆ . it should not be more than ∆ distance from the partition. Proof: We can show that the algorithm MERGEPLANES has the time complexity in O(n) by showing that for every element in plane 1. there are only a fixed number of points to be evaluated. This area can be represented in the form of a rectangle with width as ∆ and height as 2 ∆ . In other words. Y1 Y1 + Y1 - ∆ ∆ P1 ∆ P2 ∆ Also for a particular point on plane P1. For a point xi to be considered. all points in both the planes which are not more than ∆ distance apart will have to be considered in order to find the closest pair.Closest Pair Theorem I: The algorithm MERGEPLANES takes a time in O (n) to find the closest pair between two given planes. Hence. X1 . we can say that. there exists a fixed area in P2 in which all the points which need to be evaluated exist. the points which we need to consider on plane P2 must have y-coordinates between Y1 + ∆ and Y1 .

in total. the input set is sorted in the non-decreasing order of the x coordinate. It then remains to merge the two sets returned by the recursive calls. for the next step. and if there are two points then their distance would be less than ∆ . The partitioning of the given set of points can take a linear time g (n) ∈ O (n). So. we can say that there can be at most 8 points in P2 that need to be considered while evaluating any point in P1. Hence. together the MERGEPLANES algorithm will run in a time complexity of O (n) * O (1). the second for loop will find all points that are inside this rectangle of dimension ∆ by 2 ∆ . which can be proven to take a time in m (n) ∈ O (n). This is proved in the Theorem I. That is. The diagonal distance of a square is ∆ / 2 . Proof: Basis: The time complexity analysis of this algorithm can be divided into the several stages. Thus. Time complexity of this algorithm is in O (n log n). Initially. the second for loop will always execute for only 8 times. which is O (1). which is less than ∆ . Induction Step: Consider the induction step for the next iteration in which the set P is further divided into two subsets. In the algorithm. Theorem II: The algorithm findclosest takes a time in O (n log n) to find the closest pair on a given plane. the algorithm takes a time complexity of t (n) = t (n/2) + t (n/2) + cn = 2 t (n/2) + cn Note that the procedure MERGEPLANES takes O (n). So.Closest Pair The above rectangle can be divided into 8 equal squares with each square having a dimension of ∆ /2. it will run in O (n). Page 5 of 6 . The time complexity for both the sets becomes t (n) = 2 ( 2 t (n/4) + cn/2 ) + cn = 4 t (n/4) + 2 cn Similarly. The first for loop will execute for O (n) times. there are recursive calls on the two sub-sets each of size n/2. the time complexity becomes t (n) = 2 ( 4 t (n/8) + 2 cn /2 ) + cn = 8 t (n/8) + 3 cn By Induction hypothesis. MERGEPLANES. After partitioning. we can say that for all the squares in the specifies rectangle on P2 there cannot be more than one points since ∆ is the minimum distance between any two points. Thus.

n = 2k k = log 2 n t (n) = n t (1) + n c logn t (n) = n + n log n t (n) = O (n log n ) References [1] Gilles Brassard and Paul Bratley. 1999. Leiserson and Ronald L.Closest Pair t (n) = 2k t (n/2k ) + k cn Substituting. Prentice Hall of India. 1998. Rivest. Fundamentals of Algorithmics. Page 6 of 6 . Charles E. Introduction to Algorithms. Cormen. [2] Thomas H. Prentice Hall of India.

- lecture2Uploaded byMakarand Dashrath Wangikar
- BIG-OUploaded byarunkumarsh
- Lecture 03Uploaded byBraicot Espinoza Moran
- Uncapacitated Multiple AllocationUploaded byLeonardo Cetre
- 02-asympUploaded bySafdar Jafri
- lecture1[1]Uploaded byLoveleen Bhalla
- miaa360lessonstudygrade5-1Uploaded byapi-245618900
- 1 Basic ConceptsUploaded bySateesh Bonthala
- CST MelissaUploaded bynuttela89
- X06Growth.pptUploaded byferid_i04
- Questions on Artificial IntelligenceUploaded byUtkarsh Bajpai
- Almost Optimal Set Covers in Finite VC-DimensionUploaded byPritam Bhattacharya
- BigoUploaded byJimmy Fallon
- practice-sheet-1.pdfUploaded byMoazzam Hussain
- Analysis of AlgorithmsUploaded byMarko Basara
- best lpUploaded byapi-277980226
- Electronic, Signed Modalities for TelephonyUploaded byDark Dream
- 6 linear relations blm extra practice sheets answer keysUploaded byapi-349184429
- parent overview es3 graphingUploaded byapi-258656532
- Aula3_labUploaded byMarcos Antonio Silva
- A Greedy Branch-And-Bound Inclusion-Exclusion Algorithm for Calculating the Exact Multi-State Network ReliabilityUploaded byAmir Javan
- maximizing the profit of a businessUploaded byapi-260619491
- Covering Graphs using Trees and StarsUploaded byfsecuredown
- 14 (1).pdfUploaded bykulperera
- 6-Moments Couples and Force Couple Systems_Partb.pptUploaded byLevi Pogi
- Cantelever Beam PBEAMLUploaded byRoshan Dcruz
- lesson plan coordinate planesUploaded byapi-272657650
- maximizing the profit of a businessUploaded byapi-240945874
- maximizing the profit of a businessUploaded byapi-241971167
- B61393E_2_02 - Connection ManualUploaded byeisbaerle81