小编AM3*_*AM3的帖子

你能帮我计算一下这个算法的时间复杂度吗?

public static void complexityexample(int n) {
    int count = 0;
    int k = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            count++;
        }
        k *= 2;
        for (int t = 0; t < n; t++) {
            count++;
        }
        System.out.println(count);
    }
}
Run Code Online (Sandbox Code Playgroud)

有人能给我答案吗?

例如,我知道for循环中的nuber操作是2N + 2,

和count ++中的操作数; 是N.

但是对于其他部分呢.

java algorithm complexity-theory big-o time-complexity

1
推荐指数
1
解决办法
117
查看次数