Algorithmic complexity of naive code for processing all consecutive subsequences of a list: n^2 or n^3?

前端 未结 9 1105
傲寒
傲寒 2020-12-25 11:41

I\'m studying for a test and found this question:

I can\'t really determine the complexity, I figured it\'s either O(n2) or O(n3) and I\'m lea

9条回答
  •  情歌与酒
    2020-12-25 12:11

    No matter triangle shape or not, it always a complexity O(N^3), but of course with lower constant then a full triple nested cycles.

提交回复
热议问题