Algorithm to determine the closest pair in a set.