I'm looking at an algorithm and trying to break it down and come up with the Big O notation for it. However, I am unable to deduce why it is O(n^2)
I can see that the outer loop goes to N, but the inner loop is throwing me off
int a = 0;
for (i = 0; i < N; i++) {
for (j = N; j > i; j--) {
a = a + i + j;
}
}
Does anyone know how I can best approach these kinds of questions, if they were to pop up in an interview? I want to get better at analyzing algorithms