output: Points r and s, with r s, such that distance(r,s) is the shortest distance ... (a,b) d2 distance(w,z) if (d1 d2) then (r,s,d) (a,b,d1) else (r,s,d) ...
Assume that they have been sorted in ascending order of their x coordinate. ... of their x-coordinates with ties resolved by increasing order of y coordinates. ...