Skip to content

Commit 3db9a12

Browse files
committed
docs: remove redundant code
1 parent bfaaef3 commit 3db9a12

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

docs/chapter_computational_complexity/space_complexity.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@
8080
Node next;
8181
Node(int x) { val = x; }
8282
}
83-
83+
8484
/* 函数 */
8585
int function() {
8686
// 执行某些操作...
8787
return 0;
8888
}
89-
89+
9090
int algorithm(int n) { // 输入数据
9191
final int a = 0; // 暂存数据(常量)
9292
int b = 0; // 暂存数据(变量)
@@ -133,7 +133,7 @@
133133
func newNode(val int) *node {
134134
return &node{val: val}
135135
}
136-
136+
137137
/* 函数 */
138138
func function() int {
139139
// 执行某些操作...
@@ -263,7 +263,7 @@
263263
```rust title=""
264264
use std::rc::Rc;
265265
use std::cell::RefCell;
266-
266+
267267
/* 结构体 */
268268
struct Node {
269269
val: i32,
@@ -273,22 +273,22 @@
273273
/* 创建 Node 结构体 */
274274
impl Node {
275275
fn new(val: i32) -> Self {
276-
Self { val: val, next: None }
276+
Self { val, next: None }
277277
}
278278
}
279279

280280
/* 函数 */
281-
fn function() -> i32 {
281+
fn function() -> i32 {
282282
// 执行某些操作...
283-
return 0;
283+
0
284284
}
285285

286286
fn algorithm(n: i32) -> i32 { // 输入数据
287287
const a: i32 = 0; // 暂存数据(常量)
288288
let mut b = 0; // 暂存数据(变量)
289289
let node = Node::new(0); // 暂存数据(对象)
290290
let c = function(); // 栈帧空间(调用函数)
291-
return a + b + c; // 输出数据
291+
a + b + c // 输出数据
292292
}
293293
```
294294

@@ -611,14 +611,14 @@
611611
// 执行某些操作
612612
return 0
613613
}
614-
614+
615615
/* 循环的空间复杂度为 O(1) */
616616
func loop(n int) {
617617
for i := 0; i < n; i++ {
618618
function()
619619
}
620620
}
621-
621+
622622
/* 递归的空间复杂度为 O(n) */
623623
func recur(n int) {
624624
if n == 1 {

0 commit comments

Comments
 (0)