1

The question I'm faced with:

Let $A[1], A[2], ...,A[n]$ be an array containing $n$ very large positive integers.

Describe an efficient algorithm to find the minimum positive difference between any two integers in the array.

What is the complexity of your algorithm? Explain.

I would assume you apply a Merge Sort or Quick Sort $\Theta(n(log (n))$ and then scan through the array, subtracting the second element from the previous element, all the way to the end? Or $n-1$ comparisons?

So the complexity would be $\Theta(n(log(n) + (n-1))$?

0 Answers0