Hashing: Review Examples Questions
Hashing: Review Examples Questions
Review
Examples
Questions
Hashing : review
Background
How to make searching even faster?
Two steps to go
1. Design a good hash function
Fast to compute and
Minimize the number of collisions
Separate Chaining
Keep a linked list of keys that hash to the same
value
1 4371
3 1323 6173
4 4344
5
2 1989
3 1323
4 6173
5 4344
9 4199
Hashing : examples
(c) Open addressing hash table with second
hash function h2(x) =7 − (x mod 7)
0
1 4371
2
Then, what about 1989?
3 1323
4 6173
5 9679
7 4344
8
9 4199
Hashing : examples
because h2(1989) = 6,