更新时间:2021-10-09 17:45:34
@ sara JONS 您已经引用的幻灯片组 - 和算法其中
的复杂性被测量为在每个基本笔划/原子操作为环
The complexity is being measured for each primitive/atomic operation in the for loop
for(j=0 ; j<n ; j++)
{
//...
}
载玻片评论这个循环为2n + 2的原因如下:
The slides rate this loop as 2n+2 for the following reasons:
其次,对于循环中的比较
Secondly, the comparison within the for loop
if(STudID == A[j])
return true;
这是额定为N欢声笑语。因此,如果添加了+1操作,正OPS,正OPS,+1运,N OPS = 3N + 2的复杂性造成的。因此,T(N)= 3N + 2
This is rated as n ops. Thus the result if you add up +1 op, n ops, n ops, +1 op, n ops = 3n+2 complexity. So T(n) = 3n+2
认识到T(n)是不一样的O(N)。
Recognize that T(n) is not the same as O(n).