Skip to content

Commit 86a4d42

Browse files
committed
拼写修复;增加提问
1 parent 31796cc commit 86a4d42

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

docs/07_哈希表/hashtable.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ class HashTable(object):
171171
具体的实现和代码编写在视频里讲解。这个代码可不太好实现,稍不留神就会有错,我们还是通过编写单元测试验证代码的正确性。
172172

173173
# 思考题
174+
- 请你分析下哈希表插入和删除元素的平均时间复杂度是多少?我们都实现代码了,相信这个问题你可以回答上来
174175
- Slot 在二次探查法里为什么不能直接删除?为什么我们要给它定义几个状态?
175176

176177
# 延伸阅读

docs/08_字典/dict.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DictADT(HashTable):
2323
pass
2424
```
2525

26-
视频里我们将演示如何实现这些方法,并且写单侧验证正确性
26+
视频里我们将演示如何实现这些方法,并且写单测验证正确性
2727

2828
# Hashable
2929
作为 dict 的 key 必须是可哈希的,也就是说不能是 list 等可变对象。不信你在 ipython 里运行如下代码:
@@ -36,11 +36,13 @@ d[[1]] = 1
3636

3737
我引用 python 文档里的说法,大家可以自己理解下:
3838

39-
> An object is hashable if it has a hash value which never changes during its lifetime (it needs a __hash__() method), and can be compared to other objects (it needs an __eq__() or __cmp__() method). Hashable objects which compare equal must have the same hash value.
39+
```
40+
An object is hashable if it has a hash value which never changes during its lifetime (it needs a __hash__() method), and can be compared to other objects (it needs an __eq__() or __cmp__() method). Hashable objects which compare equal must have the same hash value.
4041
41-
> Hashability makes an object usable as a dictionary key and a set member, because these data structures use the hash value internally.
42+
Hashability makes an object usable as a dictionary key and a set member, because these data structures use the hash value internally.
4243
43-
> All of Python’s immutable built-in objects are hashable, while no mutable containers (such as lists or dictionaries) are. Objects which are instances of user-defined classes are hashable by default; they all compare unequal (except with themselves), and their hash value is derived from their id().
44+
All of Python’s immutable built-in objects are hashable, while no mutable containers (such as lists or dictionaries) are. Objects which are instances of user-defined classes are hashable by default; they all compare unequal (except with themselves), and their hash value is derived from their id().
45+
```
4446

4547

4648
# 思考题:

docs/09_集合/set.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# 集合 set
22

3+
集合是一种不包含重复元素的数据结构,经常用来判断是否重复这种操作,或者集合中是否存在一个元素。
34
这一章讲集合,实际上它的底层也是哈希表实现的,所以像实现 DictADT 一样,借助 HashTable 实现它也比较简单。
45

56

@@ -39,6 +40,9 @@ class SetADT(HashTable):
3940

4041

4142
# 思考题
43+
- 集合判断一个元素是否存在的时间复杂度是多少?
44+
- 集合的元素 key 需要满足什么概念?可变对象可以吗?
45+
- 请你在 SetADT 基础上实现集合的 remove 操作和 pop 操作
4246
- 你能尝试实现对称差操作吗?这里我没有实现,留给你作为练习
4347
- 你知道如何重载 python 的内置运算符吗?这里我们实现 set 的集合操作就是用到了重载,请阅读相关 python 文档。
4448

0 commit comments

Comments
 (0)