Closest/Farthest pair algorithms