Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h...
-
Upload
penelope-williamson -
Category
Documents
-
view
215 -
download
1
Transcript of Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h...
Insert using Linear Hashing
h001
4
H level (n) = level+1 bits of n Level = 0, next =
7
Insert 2, h0(2) = 0
initial
4 = 100, so h0(4) = 07 = 111, so h0(7) = 1
Insert using Linear Hashing
h001
4 2
H level (n) = level+1 bits of n Level = 0, next =
7
Insert 8, h0(8) = 0
Insert using Linear Hashing
h001
4 2
H level (n) = level+1 bits of n Level = 0, next =
7
8
No room, so insert into an overflow block, which triggers the splitting process.
Insert using Linear Hashing
h001
4 2
H level (n) = level+1 bits of n Level = 0, next =
7
8
No room, so insert into an overflow block, which triggers the splitting process.
H1(4) = 00H1(2) = 10H1(8) = 00
h100011011
Insert using Linear Hashing
h001
4 8
H level (n) = level+1 bits of n Level = 0, next =
7
h100
10 2
Denotes split bucket
No room, so insert into an overflow block, which triggers the splitting process.
H1(4) = 00H1(2) = 10H1(8) = 00
Insert using Linear Hashing
h001
4 8
H level (n) = level+1 bits of n Level = 0, next =
7
Insert 5, h0(5) = 1
Advance NEXT by one.
h100
10 2
Insert using Linear Hashing
h001
4 8
H level (n) = level+1 bits of n Level = 0, next =
7 5
Insert 3, h0(3) = 1
h100
10 2
Insert using Linear Hashing
h001
4 8
H level (n) = level+1 bits of n Level = 0, next =
7 5No room, insert into overflow and trigger a split.
h100
10 2
3
Insert using Linear Hashing
h001
4 8
H level (n) = level+1 bits of n Level = 0, next =
5Redistribute 3, 5, 7 using H1
H1(3) = 11H1(5) = 01H1(7) = 11
h100011011 2
3 7
Insert using Linear Hashing
h001
4 8
H level (n) = level+1 bits of n Level = 0, next =
5Advance Next, but it is at the bottom of the current Level.
h100011011 2
3 7
Insert using Linear Hashing
h001
4 8
H level (n) = level+1 bits of n Level = 1, next =
5So reset it to the top and increment Level to 1.
h100011011 2
3 7
Insert using Linear Hashing
4 8
H level (n) = level+1 bits of n Level = 1, next =
5Remove split indicators and only use H1
h100011011 2
3 7
Insert using Linear Hashing
4 8
H level (n) = level+1 bits of n Level = 1, next =
5
Insert 15, h1(15) = 11
h100011011 2
3 7
Insert using Linear Hashing
4 8
H level (n) = level+1 bits of n Level = 1, next =
5
h100011011 2
3 7 15No room, so insert into an overflow block, which triggers the splitting process.
Insert using Linear Hashing
4 8
H level (n) = level+1 bits of n Level = 1, next =
5
h100011011 2
3 7 15
Split Next using level+1 H functionH2(4) = 100H2(8) = 000
Insert using Linear Hashing
8
H level (n) = level+1 bits of n Level = 1, next =
5
h100011011 2
3 7 15
Split Next using level+1 H functionH2(4) = 100H2(8) = 000
h2100 4
h2000
Insert using Linear Hashing
8
H level (n) = level+1 bits of n Level = 1, next =
5
h100011011 2
3 7 15
Mark bucket as splitAdvance Next.
h2100 4
Insert using Linear Hashing
8
H level (n) = level+1 bits of n Level = 1, next =
5
h100011011 2
3 7 15
Mark bucket as splitAdvance Next.
h2100 4
And Insert and Insert and Insert ….