0 views

Uploaded by nabilshf

qsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssfqsfqsfqsfqsfqsfqsfqsfq

save

- How to Prove It
- Turing - A Novel About Computation
- Faith as a Character Trait
- Latex Guiamoy Real Analysis
- Data Sufficiency Formulae
- ccgps math 5 unit7frameworkse
- rubric
- 1 IntroToAutomataTheory.pdf
- Tcs all 70 patterns with solutions
- mt 244 portfolio
- mathematicalinduchbush2.pdf
- artist agreement fall 2015
- 4_Form_Part02.ppt
- Laws of Form
- M66 Triangle With Restricted Angle Sum - NaTriAnglSum1
- Assignment 5 - Stacks and Queues
- Quiz2_A - Answer
- Duality
- Méndez, Robles - A Class of Simpler Logical Matrices for the Variable-Sharing Property
- Rpt & Plan-j Math Year 4
- Downarowicz Tomasz
- MATLAB Lab Test Question
- Errors in Numerical Analysis PDF
- Java Applet
- Fermat
- Lecture 7
- Logic Game - SU-MA-DO - How to Solve
- Proof Technology
- math project
- slides04-4up
- elements BA.pdf
- projetdeconstructionmtallique-130316130916-phpapp01
- Mémoire-PFE_Joseph-ALBERT
- flexion composée
- Rapportdiopmoussa 150719123101 Lva1 App6891
- Elements BA
- flexion composée - dimensionnement
- Chap-LI
- guide-maitre-ouvrage.pdf
- Rapportdiopmoussa 150719123101 Lva1 App6891
- 852_preparer_entretien27567.pdf
- 6 Effort Tranchant
- Pages-269-272_Roux
- Ensam Express Num-27
- ACM-ICPCTCGroupB EngForProblemSolving Printversion
- Subgraphs, Paths, And Connected Graphdddddddddddddddddddddddddddddddddddddddddddddddddddddsfsdfsdfsdfsfsfdfsdffffffffffffffffffffffffffffffqzfqf
- Ba Effort Tranchant EC2Ba Effort Tranchant EC2Ba Effort Tranchant EC2Ba Effort Tranchant EC2Ba Effort Tranchant EC2Cours de béton armé
- A New Algorithm for Knight’s Tours
- Ural Championship - Day 1
- Cours de Beton Arme-suivant Les Regles b
- Anc Rage
- Ba Effort Tranchant EC2
- Plan Chers
- Fiche Chantidsvdvdsvdsvsdvdvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvver 09 - Martinique
- Les énergies Renouvlables au Maroc - Stratégie et plan d'action
- Guide Pose Sommairdsvsdvsdvsde

Closest Pair

Piotr Indyk

October 30, 2003 Lecture 17: Closest Pair 2

Closest Pair

• Find a closest pair among p

1

…p

n

∈R

d

• Easy to do in O(dn

2

) time

– For all p

i

p

j

, compute ||p

i

– p

j

|| and choose

the minimum

• We will aim for better time, as long as d is

“small”

• For now, focus on d=2

October 30, 2003 Lecture 17: Closest Pair 3

Divide and conquer

• Divide:

– Compute the median of x-

coordinates

– Split the points into P

L

and

P

R

, each of size n/2

• Conquer: compute the

closest pairs for P

L

and P

R

• Combine the results (the

hard part)

October 30, 2003 Lecture 17: Closest Pair 4

Combine

• Let k=min(k

1

,k

2

)

• Observe:

– Need to check only pairs which

cross the dividing line

– Only interested in pairs within

distance < k

• Suffices to look at points in

the 2k-width strip around the

median line

k

1

k

2

2k

October 30, 2003 Lecture 17: Closest Pair 5

Scanning the strip

• Sort all points in the strip

by their y-coordinates,

forming q

1

…q

r

, r n.

• Let y

i

be the y-coordinate

of q

i

• For i=1 to r

– j=i-1

– While y

i

-y

j

< d

• Check the pair q

i

,q

j

• j:=j-1

d

October 30, 2003 Lecture 17: Closest Pair 6

Analysis

• Correctness: easy

• Running time is more

involved

• Can we have many

q

j

’s that are within

distance k from q

i

?

• No

• Proof by packing

argument

k

October 30, 2003 Lecture 17: Closest Pair 7

Analysis, ctd.

Theorem: there are at most 7

q

j

’s such that y

i

-y

j

k.

Proof:

• Each such q

j

must lie either

in the left or in the right k× k

square

• Within each square, all

points have distance

distance k from others

• We can pack at most 4 such

points into one square, so

we have 8 points total (incl.

q

i

)

q

i

October 30, 2003 Lecture 17: Closest Pair 8

Packing bound

• Proving “4” is not obvious

• Will prove “5”

– Draw a disk of radius k/2

around each point

– Disks are disjoint

– The disk-square intersection

has area (k/2)

2

/4 = /16 k

2

– The square has area k

2

– Can pack at most 16/ 5.1

points

October 30, 2003 Lecture 17: Closest Pair 9

Running time

• Divide: O(n)

• Combine: O(n log n) because we sort by y

• However, we can:

– Sort all points by y at the beginning

– Divide preserves the y-order of points

Then combine takes only O(n)

• We get T(n)=2T(n/2)+O(n), so

T(n)=O(n log n)

October 30, 2003 Lecture 17: Closest Pair 10

Higher dimensions

• Divide: split P into P

L

and P

R

using the

hyperplane x=t

• Conquer: as before

• Combine:

– Need to take care of points with x in [t-k,t+k]

– This is essentially the same problem, but in d-1

dimensions

– We get:

• T(n,d)=2T(n/2)+T(n,d-1)

• T(n,1)=O

d

(1) n

– Solves to: T(n,d)=n log

d-1

n

October 30, 2003 Lecture 17: Closest Pair 11

Closest Pair with Help

• Given: P={p

1

…p

n

} of points from R

d

, such

that the closest distance is in (t,c t]

• Goal: find the closest pair

• Will give an O((c√d)

d

n) time algorithm

• Note: by scaling we can assume t=1

October 30, 2003 Lecture 17: Closest Pair 12

Algorithm

• Impose a cubic grid onto

R

d

, where each cell is a

1/√d×1/√d cube

• Put each point into a

bucket corresponding to

the cell it belongs to

• Diameter of each cell is

1, so at most one point

per cell

• For each p∈P, check all

points in cells

intersecting a ball B(p,c)

• At most (2√dc)

d

such

cells

October 30, 2003 Lecture 17: Closest Pair 13

How to find good t ?

• Repeat:

– Choose a random point p in P

– Let t=t(p)=D(p,P-{p})

– Impose a grid with side t’< t/(2√d), i.e., such

that any pair of adjacent cells has diameter <t

– Put the points into the grid cells

– Remove all points whose all adjacent cells are

empty

• Until P is empty

October 30, 2003 Lecture 17: Closest Pair 14

Correctness

• Consider t computed in the last iteration

– There is a pair of points with distance t

– There is no pair of points with distance t’ or

less*

– We get c=t/t’~ 2√d

*And never was, if the grids are nested

October 30, 2003 Lecture 17: Closest Pair 15

Running time

• Consider t(p

1

)…t(p

m

)

• An iteration is lucky if t(p

i

) t for at last half

of points p

i

• The probability of being lucky is 1/2

• Expected #iterations till a lucky one is 2

• After we are lucky, the number of points is

m/2

• Total expected time = 3

d

times

O(n+n/2+n/4+…+1)

- How to Prove ItUploaded byPBD10017
- Turing - A Novel About ComputationUploaded byRobert Pereira
- Faith as a Character TraitUploaded byskanzeni
- Latex Guiamoy Real AnalysisUploaded byRudolf Guiamoy
- Data Sufficiency FormulaeUploaded byNeha Kaplish
- ccgps math 5 unit7frameworkseUploaded byapi-234920827
- rubricUploaded byapi-352813518
- 1 IntroToAutomataTheory.pdfUploaded byBüşra Çelik
- Tcs all 70 patterns with solutionsUploaded bysri...
- mt 244 portfolioUploaded byapi-298614699
- mathematicalinduchbush2.pdfUploaded byjay appoh
- artist agreement fall 2015Uploaded byapi-297332785
- 4_Form_Part02.pptUploaded byFais Ibrahim
- Laws of FormUploaded byJuan Ignacio Heredia
- M66 Triangle With Restricted Angle Sum - NaTriAnglSum1Uploaded byNora
- Assignment 5 - Stacks and QueuesUploaded byTheAkHolic
- Quiz2_A - AnswerUploaded bylouka gamal
- DualityUploaded bywertyuiop
- Méndez, Robles - A Class of Simpler Logical Matrices for the Variable-Sharing PropertyUploaded bymicha-jarmoc-9160
- Rpt & Plan-j Math Year 4Uploaded bySyafiah Eppie
- Downarowicz TomaszUploaded byJosué Daniel Vázquez Becerra
- MATLAB Lab Test QuestionUploaded bytsanshine
- Errors in Numerical Analysis PDFUploaded byAngela
- Java AppletUploaded byAdy
- FermatUploaded bysadfadsf
- Lecture 7Uploaded byAnonymous 6iFFjEpzYj
- Logic Game - SU-MA-DO - How to SolveUploaded byGuillermo Verger
- Proof TechnologyUploaded byLokesh Gowda
- math projectUploaded byapi-237169158
- slides04-4upUploaded byJoaquin Gonzalez

- elements BA.pdfUploaded bynabilshf
- projetdeconstructionmtallique-130316130916-phpapp01Uploaded bynabilshf
- Mémoire-PFE_Joseph-ALBERTUploaded bynabilshf
- flexion composéeUploaded bynabilshf
- Rapportdiopmoussa 150719123101 Lva1 App6891Uploaded bynabilshf
- Elements BAUploaded bynabilshf
- flexion composée - dimensionnementUploaded bynabilshf
- Chap-LIUploaded bynabilshf
- guide-maitre-ouvrage.pdfUploaded bynabilshf
- Rapportdiopmoussa 150719123101 Lva1 App6891Uploaded bynabilshf
- 852_preparer_entretien27567.pdfUploaded bynabilshf
- 6 Effort TranchantUploaded bynabilshf
- Pages-269-272_RouxUploaded bynabilshf
- Ensam Express Num-27Uploaded bynabilshf
- ACM-ICPCTCGroupB EngForProblemSolving PrintversionUploaded bynabilshf
- Subgraphs, Paths, And Connected GraphdddddddddddddddddddddddddddddddddddddddddddddddddddddsfsdfsdfsdfsfsfdfsdffffffffffffffffffffffffffffffqzfqfUploaded bynabilshf
- Ba Effort Tranchant EC2Ba Effort Tranchant EC2Ba Effort Tranchant EC2Ba Effort Tranchant EC2Ba Effort Tranchant EC2Cours de béton arméUploaded bynabilshf
- A New Algorithm for Knight’s ToursUploaded bynabilshf
- Ural Championship - Day 1Uploaded bynabilshf
- Cours de Beton Arme-suivant Les Regles bUploaded bynabilshf
- Anc RageUploaded bynabilshf
- Ba Effort Tranchant EC2Uploaded bynabilshf
- Plan ChersUploaded bynabilshf
- Fiche Chantidsvdvdsvdsvsdvdvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvver 09 - MartiniqueUploaded bynabilshf
- Les énergies Renouvlables au Maroc - Stratégie et plan d'actionUploaded bynabilshf
- Guide Pose SommairdsvsdvsdvsdeUploaded bynabilshf