File tree Expand file tree Collapse file tree 7 files changed +1020
-4
lines changed Expand file tree Collapse file tree 7 files changed +1020
-4
lines changed Original file line number Diff line number Diff line change 2
2
/site /
3
3
/env /
4
4
__pycache__ /
5
- uv.lock
6
5
.roo /
7
6
docs /projects /log /
8
7
docs /projects /assets /log /
9
8
docs /draft /
9
+ /en /
Original file line number Diff line number Diff line change 32
32
[ ![ bash] ( https://www.vectorlogo.zone/logos/gnu_bash/gnu_bash-ar21.svg )] ( https://www.gnu.org/software/bash/?utm_source=vectorlogozone&utm_medium=referrer ) {target="_ blank"}
33
33
[ ![ bluetooth] ( https://www.vectorlogo.zone/logos/bluetooth/bluetooth-ar21.svg )] ( https://www.bluetooth.com/?utm_source=vectorlogozone&utm_medium=referrer ) {target="_ blank"}
34
34
[ ![ curl] ( https://www.vectorlogo.zone/logos/curl_haxx/curl_haxx-ar21.svg )] ( https://curl.haxx.se/?utm_source=vectorlogozone&utm_medium=referrer ) {target="_ blank"}
35
+ [ ![ GeeksforGeeks] ( https://media.geeksforgeeks.org/gfg-gg-logo.svg )] ( https://www.geeksforgeeks.org/?utm_source=vectorlogozone&utm_medium=referrer ) {target="_ blank"}
35
36
[ ![ debian] ( https://www.vectorlogo.zone/logos/debian/debian-ar21.svg )] ( https://www.debian.org/?utm_source=vectorlogozone&utm_medium=referrer ) {target="_ blank"}
36
37
[ ![ docker] ( https://www.vectorlogo.zone/logos/docker/docker-ar21.svg )] ( https://www.docker.com/?utm_source=vectorlogozone&utm_medium=referrer ) {target="_ blank"}
37
38
[ ![ fontawesome] ( https://www.vectorlogo.zone/logos/font-awesome/font-awesome-ar21.svg )] ( http://fontawesome.io/?utm_source=vectorlogozone&utm_medium=referrer ) {target="_ blank"}
Original file line number Diff line number Diff line change 98
98
\end{aligned}
99
99
$$
100
100
101
- # ## 常数阶
101
+ # ## 常数阶 $O(1)$
102
+
103
+ 常数阶的操作数与输入数据量无关,即不随输入数据大小的变化而增大,始终为一个常数。
104
+
105
+ 如普通的赋值语句:
106
+ ```py
107
+ def assign(n: int ) -> int :
108
+ res = n # 常数阶
109
+ return res
110
+ ```
111
+
112
+ !!! warning
113
+ 需要注意的是,常数阶的定义是** 操作数量与输入数据大小无关** ,因此即便一个程序的输入数据大小很大(必须是一个常量),如下面的例子:
114
+ ```py
115
+ def sum_to_const(n: int ) -> int :
116
+ """ Sum from 0 with step n, size times."""
117
+ count = 0
118
+ size = 10000
119
+ for _ in range (size):
120
+ count + = n
121
+ return count
122
+ ```
123
+ 这是一个求和函数,用于将输入数据`n` 相加`size` 次。
124
+
125
+ 虽然我们在编写程序时可以将`size` 设置得很大,但在程序运行时,无论输入数据的大小如何,求和的操作次数永远只执行`size` 次,即** 不随输入数据大小的变化而增大** ,因此上面示例的时间复杂度只是一个** 常数阶** 。
126
+
127
+ # ## 线性阶 $O(n)$
128
+
129
+ 线性阶的操作数与输入数据大小 $ n$ 呈** 线性相关** ,常以单层循环的形式出现:
130
+
131
+ ```py
132
+ def for_linear(n: int ) -> int :
133
+ sum = 0
134
+ for _ in range (n):
135
+ count + = 1
136
+ return sum
137
+ ```
138
+
139
+ 线性阶算法常出现在[** 线性表** ](https:// www.geeksforgeeks.org/ dsa/ introduction- to- linear- data- structures/ )的遍历中;在这中情景下,输入数据一般为待遍历线性表的长度(或大小):
140
+ ```py
141
+ def throughout_arr(nums: list[int ]) -> int :
142
+ count = 0
143
+ for num in nums:
144
+ count + = num
145
+ return count
146
+ ```
147
+
148
+ # ## 平方阶 $O(n^2)$
149
+
150
+ 平方阶的操作数可以看作是输入数据大小 $ n$ 的一个二次函数,通常出现在** 嵌套循环** 中。
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ comments: true
75
75
76
76
<!-- recent_notes_start -->
77
77
<ul >
78
- <li ><div style =" display :flex ; justify-content :space-between ; align-items :center ;" ><a href =" dsa/anal/time/ " >算法时间复杂度</a ><span style =" font-size :0.8em ;" >2025-08-16 </span ></div ></li >
78
+ <li ><div style =" display :flex ; justify-content :space-between ; align-items :center ;" ><a href =" dsa/anal/time/ " >算法时间复杂度</a ><span style =" font-size :0.8em ;" >2025-08-20 </span ></div ></li >
79
79
<li ><div style =" display :flex ; justify-content :space-between ; align-items :center ;" ><a href =" dsa/anal/iter_and_recu/ " >迭代与递归</a ><span style =" font-size :0.8em ;" >2025-08-15</span ></div ></li >
80
80
<li ><div style =" display :flex ; justify-content :space-between ; align-items :center ;" ><a href =" tools/git/ " >Git</a ><span style =" font-size :0.8em ;" >2025-08-13</span ></div ></li >
81
81
<li ><div style =" display :flex ; justify-content :space-between ; align-items :center ;" ><a href =" tools/linux/tmux/ " >tmux</a ><span style =" font-size :0.8em ;" >2025-08-13</span ></div ></li >
Original file line number Diff line number Diff line change @@ -203,6 +203,13 @@ validation:
203
203
204
204
# # Additional configuration
205
205
extra :
206
+ alternate :
207
+ # - name: 简体中文
208
+ # link: /
209
+ # lang: zh
210
+ # - name: English
211
+ # link: /en/
212
+ # lang: en
206
213
status :
207
214
new : Recently added
208
215
deprecated : Deprecated
@@ -212,6 +219,8 @@ extra:
212
219
social :
213
220
- icon : fontawesome/brands/github
214
221
link : https://github.com/virtualguard101
222
+ - icon : fontawesome/brands/x-twitter
223
+ link : https://x.com/virtualguardi01
215
224
216
225
# # Page tree
217
226
nav :
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ class LinkData:
36
36
# link_icon='material/notebook',
37
37
# ),
38
38
LinkData (
39
- name = 'Blog with Hexo ' ,
39
+ name = 'Blog with Anime ' ,
40
40
url = 'https://blog.virtualguard101.com' ,
41
41
description = '' , # 添加描述
42
42
button_icon = 'fontawesome/solid/blog' ,
You can’t perform that action at this time.
0 commit comments