The answer is B $O(n^2)$.
The reasoning behind this is that you essentially calculate the distance between all the pairs of points. Assuming there are n numbers, you calculate the distance (based on this algorithm) for $n \dfrac{(n-1)}{2}$ pairs, hence $O(n^2)$.
Since all numbers are on the number line, this can be done in a more efficient way, i.e. sort the points in the line and the traverse the list of points to find the closest.