How to calculate the runtime of a following code? Could someone explain how to calculate the Big O notation for a runtime of a snippet of a code?
for (int i=0; i&lt;list.length; i++) {
    for (int j=0; j&lt;list.length; j++) {
        for (int k=0; k&lt;list.length; k++) {
            if (k%2==0) {
               list[i] += list[j];
            } else {
               list[i] += list[k];
            }
       }
   }
}

From my understanding, I'm thinking it's something like O(n^3) because the statement is executive n times for every i?
If I understand correctly, that you denote $n$=list.length and are calculating amount of   &quot;list[i] +=&quot; operation. Then of course, as it is triple loop, then for $n$ times  fixed &quot;i&quot; from first loop you take $n$ times &quot;j&quot; from second loop and $n$ times &quot;k&quot; from most inner, third, loop. So operation &quot;list[i] +=&quot; will be fulfilled exactly $n^3$ times. Now knowing, that $n^3 \in O(n^3)$ you can state that complexity for whole snippet is $O(n^3)$ .