implement and test the closest pair algorithm