Solution
This computational geometry problem has many applications in computer graphics and vision. A naive algorithm with quadratic running time iterates through all pairs of points to find the closest pair. Our goal is to design an time divide-and-conquer algorithm.
To solve this problem in time , let’s first split the given points by an appropriately chosen vertical line into two halves, and , of size (assume for simplicity that all -coordinates of the input points are different). By making two recursive calls for the sets and , we find the minimum distances and in these subsets. Let = min{, }.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.