2
for(int i = 0; i < N*N; i++) {
   for(int j = 0; j < i; j++) {
      //something O(1)
   }
}

So I was trying to find big O of this function.

The outer loop is O(N^2) alone, and the inner loop goes from 0 to N^2. So I was thinking this would make the whole thing O(N^4). Am I correct in thinking this?

Adam M
  • 21
  • 1

1 Answers1

0

Yes, you are correct. The time complexity of the code is O(N^4).

Aleksa Majkic
  • 632
  • 5
  • 17