Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8c75fc4

Browse files
committed
Update 02.Algorithm-Complexity.md
1 parent 40158e2 commit 8c75fc4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎Contents/00.Introduction/02.Algorithm-Complexity.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def algorithm(n):
187187

188188
上述代码中 `cnt = 1` 的时间复杂度为 $O(1)$ 可以忽略不算。`while` 循环体中 $cnt$ 从 1ドル$ 开始,每循环一次都乘以 2ドル$。当大于等于 $n$ 时循环结束。变量 $cnt$ 的取值是一个等比数列:2ドル^0, 2^1, 2^2, ..., 2^x,ドル根据 2ドル^x = n,ドル可以得出这段循环体的执行次数为 $\log_2n,ドル所以这段代码的时间复杂度为 $O(\log_2n)$。
189189

190-
因为 $\log n = k \times \log_2 n,ドル这里 $k = 3.322,ドル所以,$\log n$ 与 $\log_2 n$ 的差别比较小。为了方便书写,通常我们将对数时间复杂度写作是 $O(\log n)$。
190+
因为 $\log_2 n = k \times \log_{10} n,ドル这里 $k \approx 3.322,ドル是一个常数系数,$\log_2 n$ 与 $\log_{10} n$ 之间差别比较小,可以忽略 $k$。并且 $\log_{10} n$ 也可以简写成 $\log n,ドル所以为了方便书写,通常我们将对数时间复杂度写作是 $O(\log n)$。
191191

192192
#### 2.3.6 线性对数 $O(n \times \log n)$
193193

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /