algorithm - 这个代码块的时间复杂度是多少?

标签 algorithm time-complexity

如何计算时间复杂度?

While(n>0)
      For j in n
          Count+=1
      n = n/2

最佳答案

O(n)

n+ n/2 + n/4 + ... = 2n = O(n)

关于algorithm - 这个代码块的时间复杂度是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56591600/

相关文章:

java - 条件空对象 : Comparison method violates its general contract

algorithm - 得到T(n)=T(n/4)+T(3n/4)+c的复杂度

algorithm - 最大流算法运行时间

algorithm - 未知移位的二进制搜索修改

javascript - 2个数组之间的链接

c++ - 在 C++ 中评估数学表达式

c# - 字节公因数

algorithm - i 以变量(不是 1 或 0)开始的 for 循环的时间复杂度

loops - 为什么是 O(log(logn)) 而不是 O(logn)

algorithm - 回文递归算法的时间复杂度