Академический Документы
Профессиональный Документы
Культура Документы
1 (key, record)
. . .
4
Issues?
What hash function? Overflow? How to store records?
Record storage
1. Whole record
h(key)
. . .
record
. . .
record
Delete
h(b) = 2 h(c) = 1
Questions
Q: Do we keep keys sorted inside a block?
Desired property
Uniformity: same # of keys for every bucket
Reference
The Art of Computer Programming Vol. 3 by Knuth
9
10
Idea 1
Periodic reorganization
10 20 30 33 40 50 60 70 80 90 40 50 60
10 20 30 33 40 50
11
Idea 2
Why dont we split a bucket when it overflows?
0
Insert: h(g) = 1
1
c e
b
12
00110101
use i grows over time
13
h(c)
. . .
. . .
14
Example
h(k) is 4 bits; 2 keys/bucket Insert 0111, 1010
i= 1
0 1
1 0001
1 1001 1100
15
Example continued
i=2
00 01 10 11
Insert 0000
2 1100
16
Example continued
0000 2
i=2
00 01 10 11
0001 0111 2
1001 2 1010
Insert 1011
1100 2
17
18
Duplicate keys
Insert 0001
i= 1
0 1
1 0001 0001
19
20
Space Waste
0000 4 0000
i =4
0001 4
1
21
22
0001
2 1001 b
2 1100 c
24
Indirection
Up to 2 disk accesses to access a key
25