x=x+1 ; // constant time
// executes n times
for (i≡ 1 ; i<≡ n; i++
m=m+2 // constant time
//outer loop executes n times
for (i=1; i<=n; i++) {
// inner loop executed n times
for (j=1; j<=n; j++)
k=k+1; // constant time
}
此代码的时间复杂度函数是什么,thetaΘ-算法是什么? (对不起,我的英语)
答案 0 :(得分:0)
完全根据您的分析,时间复杂度为:
(1 + n + n^2) in \Theta(n^2) and O(n^2)
n^2
用于嵌套循环。