我不确定以下C块的复杂性:
int i = 0, j = 1; for ( i = 0; i < n * n; i += j ) { O1(); j += 2; }
其中O1是一个显然需要恒定时间执行的函数.现在,我知道每次迭代其计数器增加一个常量的循环通常具有复杂性O(sqrt(n)),但这也是这种情况吗?或者是O(sqrt(n^2)),是O(n)吗?
O(sqrt(n))
O(sqrt(n^2))
O(n)
谢谢
c complexity-theory time-complexity
c ×1
complexity-theory ×1
time-complexity ×1