How to calculate the runtime of a following code?
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)$ .