What is the complexity of this nested triple for loop?

后端 未结 5 1556
小蘑菇
小蘑菇 2020-12-14 22:55

I have searched a bit on StackOverflow and have understood the complexity up to the point of the j-loop, which is O(n2). However with the nested addi

5条回答
  •  忘掉有多难
    2020-12-14 23:48

    Take a look at this example for evaluating worst case complexity.

    In essence, if you evaluate it line by line, you will get to something like O(n^3 / C), where C is some constant, normally skipped in such evaluations, leading to O(n^3).

提交回复
热议问题