I know the big-O complexity of this algorithm is O(n^2), but I cannot understand why.
O(n^2)
int sum = 0; int i = 1; j = n * n; while (i++ < j--) s
Let m be the number of iterations taken. Then,
i+m = n^2 - m
which gives,
m = (n^2-i)/2
In Big-O notation, this implies a complexity of O(n^2).