How many instructions as a function of the input size N?
int count=0;
for (int i=0; i<N; i++)
for(int j=i+1; j<N; j++)
if(a[i] + a[j] ==0)
count++;
# of "less than" compare instructions = 1/2(N+1)(N+2) Can someone pl. explain why there is 1/2 multiplier?
# of "equal to" compare instructions = 1/2 * N * (N-1). The same here why is there 1/2 * (N-1). Shouldn't it be just N?
also when do we increment j++?, after count++ or after we increment i?
Thank you!