相关疑难解决方法(0)

分析我的程序的时间复杂性

我在确定算法的时间复杂性方面存在问题.

for(int i=0;i <n i++){}   O(n)

for(int i= 0 ;i<n ;i++){    O(n^2)
  for(int j=0;j<n;j++){ 

  }
}
Run Code Online (Sandbox Code Playgroud)

现在,对于以下代码的复杂性

for(i =0; i<n ; i++) {}
for (j=0;j<n ;j++ ) {} 
Run Code Online (Sandbox Code Playgroud)

它是O(2n),因为它开发了2个单独的循环?

如果我开始j = 5到n怎么办?

algorithm complexity-theory

5
推荐指数
1
解决办法
1366
查看次数

标签 统计

algorithm ×1

complexity-theory ×1