Hashing
Hashing
• Note that any search in a table never gives • O(1) -> Get what I want at one step (1 disk
O(1) access)
• Time complexity=O(log n)
– If h(r) = 7 =GLOBAL
binaryDEPTH
111, it is in bucket pointed to
by 11. 2 1
Bucket B
00 1* 5* 7* 13*
01
10 2
Bucket C
10*
11
DIRECTORY
Handling Inserts
2 2
1
Bucket B
00 1* 5* 21*
7* 13*
01
10 2
Bucket C
10*
11
DIRECTORY 2
Bucket D
7* 19* 15*
LOCAL DEPTH 3 3
LOCAL DEPTH
2 32*16*
Bucket A
GLOBAL DEPTH 32* 16* Bucket A
4* 12* 32*16* GLOBAL DEPTH
2 2
00 1* 5* 21*13* Bucket B
3 2
000 1* 5* 21* 13* Bucket B
01 001
10 2 2
010
11 10* Bucket C Bucket C
011 10*
100
2
101 2
Bucket D
15* 7* 19*
110 15* 7* 19* Bucket D
111
3
3
4* 12* 20* Bucket A2
(`split image' 4* 12* 20* Bucket A2
of Bucket A) (`split image'
of Bucket A)
Points to Note
• 20 = binary 10100. Last 2 bits (00) tell us r in either A or A2.
Last 3 bits needed to tell which.
• Global depth of directory: Max # of bits needed to tell which
bucket an entry belongs to.
• Local depth of a bucket: # of bits used to determine if an entry
belongs to this bucket.
• When does split cause directory doubling?
• Before insert, local depth of bucket = global depth. Insert causes
local depth to become > global depth; directory is doubled by
copying it over and `fixing’ pointer to split image page.
Comments on Extendible Hashing
Delete:
•If removal of data entry makes bucket empty, can be
merged with `split image’