||I have a small doubt regarding the while loop, and how it's executed at most N times. I agree that
is executed at most N times, but what about the conditions inside while loop?
I am talking about
while(j<N-1) && (A[i]-A[j] > D)
those comparisons are surely made at most N2 times right? Why are we not counting them?
This must be something basic, but I don't know.