1
COMP 250
Lecture 27
hashing
- Nov. 10, 2017
hashing Nov. 10, 2017 1 RECALL: Map keys (type K) values (type - - PowerPoint PPT Presentation
COMP 250 Lecture 27 hashing Nov. 10, 2017 1 RECALL: Map keys (type K) values (type V) Each (key, value) pairs is an entry. For each key, there is at most one value. 2 RECALL Special Case: keys are unique positive integers in
1
2
3
4 9 12 22 3 6 8 14
4
5
: 4 : 9 : 12 : 22
m-1
3 6 8 14
{−231, … 0, … , 231 − 1}
6
: 4 : 9 : 12 : 22 m-1 3 6 8 14
{−231, … 0, … , 231 − 1}
7
:
m-1
3 6 8 14
{−231, … 0, … , 231 − 1}
8
hashcode compression
: 4 : 9 : 12 : 22 m-1 3 6 8 14
9
10
hashcode() “compression”
: 4 : 9 : 12 : 22 m-1 3 6 8 14
11
hashcode() “compression”
: 4 : 9 : 12 : 22 m-1 3 6 8 14
“hash values”
12
hashcode() “compression”
: 4 : 9 : 12 : 22 m-1 3 6 8 14
“hash values”
13
: 4 : 9 : 12 : 22 m-1 3 6 8 14
Note simpler linked list notation here.
14
15
16
https://en.oxforddictionaries.com/definition/hash#hash_Noun_200
17
: 4 : 9 : 12 : 22 m-1 3 6 8 14
18
: : 9 : : 22 m-1 3 6 8 14
19
20
21
22
23
24
25
26
27
28
29
All strings 128 bit strings
Many to one (scrambled)
30
31
32
33
34
35
36
password h(password) message encrypted message hashing encryption decryption