【算法】C = F(N, I, A)

O(f(n)),给出了算法运行时间的上界,也就是最坏情况下的时间复杂度;

大O运算规则:

(1) O(f)+O(g)=O(max(f, g))

(2) O(f)+O(g)=O(f+g)

(3) O(f)O(g)=O(fg)

(4) 如果g(N)=O(f(N)), 则O(f)+O(g)=O(f)

(5) O(Cf(N))=O(f(N)), 其中C是一个正常数

(6) f=O(f)

int index = 5;
int item = list[index];
if (condition true) then
   perform some operation that runs in constant time
else
   perform some other operation that runs in constant time
for i = 1 to 100
   for j = 1 to 200
      perform some operation that runs in constant time

这段代码的时间复杂度是常数

T(n) =O(M) 和M= O(T(n)) ,其中M≥n> 1 的算法被称作“指数时间算法”。

Ω(f(n)),给出了算法运行时间的下界,也就是最好情况下的时间复杂度;

Θ(f(n)),给出了算法运行时间的上界和下界,这里Θ(f(n))是渐近的确界,

在这里插入图片描述
微信公众号“计算机基础学”关注我哟

发布了57 篇原创文章 · 获赞 13 · 访问量 3175

猜你喜欢

转载自blog.csdn.net/qq_41985559/article/details/102010255