private int computeMinDistance(Point[] points, int start, int end){
        if(end - start == 1){
            Point p1 = points[start];
            Point p2 = points[end];
            return (p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y);
        }else if(end - start == 2){
            Point p1 = points[start];
            Point p2 = points[end-1];
            Point p3 = points[end];
            return Math.min(Math.min((p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y),
                    (p1.x - p3.x)*(p1.x - p3.x) + (p1.y - p3.y)*(p1.y - p3.y)),
                    (p2.x - p3.x)*(p2.x - p3.x) + (p2.y - p3.y)*(p2.y - p3.y));
        }else{
            throw new IllegalArgumentException();
        }
    }
http://www.geeksforgeeks.org/closest-pair-of-points-onlogn-implementation/
https://www.youtube.com/watch?v=_pSl90jq-m0 another good explanation
Given coordinates of points find closest pair points distance.

Test cases:
Number of points should be more than 1
Test along positive and negative axis

The way it works is
1) Sort by x coordinate
2) Recursively divide into two halves.
3) Find min distance between points in each half. Say this distance is d.
4) Find points which are in either half and closer than d. To find this point sort by y
axis and find distance to next 6 points. Magic about 6 points is we can create a rectangular
area and only 6 points can fit in that rectangular area. So we need to check only 7 points
for each point in rectangular area.
@author tusroy
src/com/interview/geometry/ClosestPairOfPoints.java