Skip to content

Commit 84d6729

Browse files
committed
fix Aha-Algorithms chapter2
1 parent 7a3bbf9 commit 84d6729

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

Aha-Algorithms/chapter2/2.2 stack.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
const Stack = require('./Stack.js');
77

8-
98
/**
109
* 判断是否回文
1110
* @param str

Aha-Algorithms/chapter2/2.4 list.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"use strict";
22

3-
const List = require('./List.js');
4-
const ListNode = require('./ListNode.js');
3+
const {List, ListNode} = require('./List.js');
54

65
class SortList extends List {
7-
86
/**
97
* 按数字顺序插入 value
108
* @param value

Aha-Algorithms/chapter2/List.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
const ListNode = require('./ListNode.js');
1+
/**
2+
* list 实现
3+
*/
4+
5+
class ListNode {
6+
constructor(value, next = null) {
7+
this.value = value;
8+
this.next = next;
9+
}
10+
}
211

312
class List {
413
constructor() {
@@ -33,4 +42,7 @@ class List {
3342

3443
}
3544

36-
module.exports = List;
45+
module.exports = {
46+
List,
47+
ListNode
48+
}

Aha-Algorithms/chapter2/ListNode.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

Aha-Algorithms/chapter2/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ FIFO,先进先出数据结构
99

1010
在头部 head 进行删除操作,出队
1111
在尾部 tail 进行增加操作,入队
12-
当 head = tail 时为 空队列
12+
当 head = tail 时为空队列
1313

1414
队列的实现,应该来说是通过 list 链表,不过这里我按照书中的例子,使用了数组实现
1515

@@ -19,7 +19,7 @@ FIFO,先进先出数据结构
1919

2020
只能在一端进行插入和删除操作
2121

22-
一维数组 + top 指向顶部实现了 ,top = 0 为空栈
22+
一维数组 + top 指向顶部实现了`` ,top = 0 为空栈
2323

2424
栈的应用
2525
- 判断回文字符串
@@ -28,14 +28,13 @@ FIFO,先进先出数据结构
2828

2929
## 链表 List
3030

31-
链表是一种在某些场景下比数组方便的数据结构
31+
链表是一种在某些场景下比数组方便的数据结构
3232
list 有很多类型
3333
- 单向链表
3434
- 双向链表
3535
- 循环链表
3636

37-
书中目前就介绍了最简单的 单向链表
38-
37+
书中目前就介绍了最简单的`单向链表`
3938

4039
## 关于 2.3 书上代码有错误
4140

0 commit comments

Comments
 (0)