File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -115,10 +115,11 @@ Python 抽象程度比较高, 我们能用更少的代码来实现功能,同
115
115
116
116
## 算法可视化
117
117
118
- 学习算法的过程中有时候会比较抽象,这里给大家推荐一些可视化的网站,方便更直观地理解 :
118
+ 学习算法的过程中有时候会比较抽象,这里给大家推荐一些可视化的网站,方便更直观地理解各种算法和数据结构的执行步骤 :
119
119
120
120
- https://github.com/algorithm-visualizer/algorithm-visualizer
121
121
- https://www.cs.usfca.edu/~galles/visualization/Algorithms.html
122
+ - https://runestone.academy/runestone/books/published/pythonds/index.html#
122
123
123
124
## 讲课形式
124
125
Original file line number Diff line number Diff line change 22
22
我们先来看看 list 可以不?对照这个三个需求,看看能否满足:
23
23
24
24
- 1.我们选择了 list
25
- - 2.看起来队列需要从头删除,向尾部增加元素,也就是 list.insert(0, element ) 和 list.append(element)
26
- - 3.嗯,貌似 list.insert(0, element) 会导致所有list元素后移 ,O(n)复杂度。append 平均倒是O(1),但是如果内存不够还要重新分配内存。
25
+ - 2.看起来队列需要从头删除,向尾部增加元素,也就是 list.pop(0 ) 和 list.append(element)
26
+ - 3.嗯,貌似 list.pop(0) 会导致所有其后所有元素向前移动一个位置 ,O(n)复杂度。append 平均倒是O(1),但是如果内存不够还要重新分配内存。
27
27
28
- 你看,使用了 list 的话频繁 insert(0, element) 和 append 都是非常低效的 。
28
+ 你看,使用了 list 的话频繁 pop(0) 是非常低效的 。
29
29
30
30
脑子再转转, 我们第二章实现了 链表 LinkedList,看看能否满足要求:
31
31
- 1.这里选择 LinkedList
You can’t perform that action at this time.
0 commit comments