小编Spa*_*tti的帖子

这个 for 循环 for (int j = i; j < n; j++) 的复杂度是多少?

第二个 for 循环的复杂度是多少?会是ni吗?根据我的理解,第一个 for 循环将执行 n 次,但第二个 for 循环中的索引设置为 i 。

//where n is the number elements in an array
for (int i = 0; i < n; i++) {
 for (int j = i; j < n; j++) {
   // Some Constant time task
 }
}
Run Code Online (Sandbox Code Playgroud)

complexity-theory time-complexity

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

complexity-theory ×1

time-complexity ×1