The Closest Pair Problem:

An Efficient Divide and Conquer Solution



Introduction





Closest Pair Problem



Outline

  1. Review Master Method

  2. Solutions for 1 dimension

  3. Solutions for 2 dimensions


Clickable Text: Yellow and Light Blue



Review: Master Method





Master Method: Book version



Master Method: Alternate Conditions



1D Closest Pair





1D Closest Pair Problem - Brute Force



1D Closest Pair Problem - Divide and Conquer



Now 2D





Closest Pair Problem



Brute Force



Divide and Conquer: Naive



Improvement: Use a Slab: Naive Version



Checking the Slab More Efficiently



Why 7?



Sort the Slab - Many Times



How to Avoid Sorting the Slab Each Time?



What Can go Wrong?



Array of Triples



Merge Solution



And We're Done!