Skip to content

Commit 7a6693b

Browse files
committed
Add class 7 topics, resources, and challenges: maps and hash tables
1 parent 9739658 commit 7a6693b

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

Class7.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Class 7: Maps & Hash Tables
2+
3+
### Topics
4+
- Abstract data types: [map (dictionary, associative array)][map]
5+
- Concrete data structures: [hash table]
6+
- [Hash functions], [collision resolution], [load factor], [dynamic resizing]
7+
8+
### Resources
9+
- Review Make School's [hash table slides]
10+
- Watch Make School's [hash table video lecture]
11+
- Play with VisuAlgo's [interactive hash table visualization][visualgo hash table]
12+
13+
### Challenges
14+
- Add new features to improve `HashTable` class using [hash table starter code]:
15+
- Add `size` property that tracks the number of hash table entries in constant time
16+
- Implement `load_factor` - return the [load factor], the ratio of number of entries to buckets
17+
- Implement `_resize` - perform [dynamic resizing] when `load_factor` exceeds `0.75` after an insertion (`set` is called with a new `key`) and rehash all key-value entries
18+
- Run `python hashtable.py` to test `HashTable` class instance methods on a small example
19+
- Run `pytest hashtable_test.py` to run the [hash table unit tests] and fix any failures
20+
- Annotate methods with complexity analysis of running time and space (memory)
21+
22+
### Stretch Challenges
23+
- Implement an alternative hash table [collision resolution] strategy instead of [separate chaining] (popular variants include [linear probing], [quadratic probing], and [double hashing])
24+
- Write additional test cases to expand the [hash table unit tests] to ensure your collision resolution strategy is robust
25+
26+
27+
[map]: https://en.wikipedia.org/wiki/Associative_array
28+
[hash table]: https://en.wikipedia.org/wiki/Hash_table
29+
[hash functions]: https://en.wikipedia.org/wiki/Hash_function
30+
[load factor]: https://en.wikipedia.org/wiki/Hash_table#Key_statistics
31+
[dynamic resizing]: https://en.wikipedia.org/wiki/Hash_table#Dynamic_resizing
32+
[collision resolution]: https://en.wikipedia.org/wiki/Hash_table#Collision_resolution
33+
[separate chaining]: https://en.wikipedia.org/wiki/Hash_table#Separate_chaining
34+
[linear probing]: https://en.wikipedia.org/wiki/Linear_probing
35+
[quadratic probing]: https://en.wikipedia.org/wiki/Quadratic_probing
36+
[double hashing]: https://en.wikipedia.org/wiki/Double_hashing
37+
38+
[hash table slides]: slides/HashTables.pdf
39+
[hash table video lecture]: https://www.youtube.com/watch?v=nLWXJ6IDKmQ
40+
[visualgo hash table]: https://visualgo.net/hashtable
41+
42+
[hash table starter code]: source/hashtable.py
43+
[hash table unit tests]: source/hashtable_test.py

ReadMe.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
| 4 | Monday, October 30 | [Arrays & Linked Lists](Class4.md) |
1616
| 5 | Wednesday, November 1 | [Lists, Stacks & Queues](Class5.md) |
1717
| 6 | Friday, November 3 | [Call Routing Project](Class6.md) |
18-
| 7 | Monday, November 6 | Map & Hash Table |
18+
| 7 | Monday, November 6 | [Maps & Hash Tables](Class7.md) |
1919
| 8 | Wednesday, November 8 | Set & Circular Buffer |
2020
| 9 | Friday, November 10 | Trees |
2121
| 10 | Monday, November 13 | Tree Traversals |

0 commit comments

Comments
 (0)