c++ - 大 O 符号帮助

标签 c++ big-o

while (n >= 1)

n /= 2;

我无法为此获得 Big-O 符号

最佳答案

为了便于说明,我将遵循 Pointy 的建议。

尝试 8。

4 2 1 0: 4 iterations.

尝试 32。

16 8 4 2 1 0: 6 iterations.

尝试 66。

33 16 8 4 2 1 0: 7 iterations.

那么……初始数字如何变化,迭代次数如何变化?

关于c++ - 大 O 符号帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3886643/

相关文章:

c++ - 将军树高度

algorithm - 运行时分析说明

c++ - 抛出 constexpr 函数

c++ - 在 textmate 中使用 cin 和 cout

c++ - 使用 std::set 并保留输入顺序

recursion - 该函数的大 O 表示法

c++ - 如何判断两个指针是否指向同一 block 内存

C++11 模板 : How to ensure that the type inherits a class?

algorithm - 动态规划 : design an algorithm that is in O(n log n) time

algorithm - 大θ边界,算法分析