What is the complexity of this nested triple for loop?

后端 未结 5 1542
小蘑菇
小蘑菇 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:59

    If you're accustomed to Sigma Notation, here is a formal way to deduce the time complexity of your algorithm (the plain nested loops, precisely):

    enter image description here

    NB: the formula simplifications might contain errors. If you detect anything, please let me know.

提交回复
热议问题