Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Time complexity 下面代码的大θ是多少?[I*I<;=n]_Time Complexity_Complexity Theory_Code Complexity - Fatal编程技术网

Time complexity 下面代码的大θ是多少?[I*I<;=n]

Time complexity 下面代码的大θ是多少?[I*I<;=n],time-complexity,complexity-theory,code-complexity,Time Complexity,Complexity Theory,Code Complexity,虽然我不知道从这里该怎么走。我应该从I=0到n计算n/I之和吗?在这种情况下,当存在变量(n)时,如何计算总和 我知道如果我找到L,我会找到需要的迭代次数。当它在L=N/L后终止时,我不能用N来计算L 我对此感到非常困惑。任何洞察都将不胜感激。外部循环有N次迭代。内部循环有平方根(N)迭代。将这两者相乘得出答案 for (k = 1; k <= n; k++) for (i = 1; i*i <= n; i++) // some O(1) operations`

虽然我不知道从这里该怎么走。我应该从I=0到n计算n/I之和吗?在这种情况下,当存在变量(n)时,如何计算总和

我知道如果我找到L,我会找到需要的迭代次数。当它在L=N/L后终止时,我不能用N来计算L


我对此感到非常困惑。任何洞察都将不胜感激。

外部循环有N次迭代。内部循环有平方根(N)迭代。将这两者相乘得出答案

for (k = 1; k <= n; k++)
   for (i = 1; i*i <= n; i++)
       // some O(1) operations`
I                # of interations
1               n
2               n/2
3               n/3
.                .
.                .
.                .
n/L              1