Insert using Linear Hashing
description
Transcript of Insert using Linear Hashing
Insert using Linear Hashing
h001
4
H level (n) = level+1 right most bits of n Level = 0, next =
7
Insert 5, h0(5) = 1
initial
4 = 100, so h0(4) = 07 = 111, so h0(7) = 1
Insert using Linear Hashing
h001
4
H level (n) = level+1 bits of n Level = 0, next =
7 5
Insert 9, h0(9) = 1
Insert using Linear Hashing
h001
4
H level (n) = level+1 bits of n Level = 0, next =
7 5 9 No room, so create an overflow block, which triggers the splitting process.
Insert using Linear Hashing
h001
4
H level (n) = level+1 bits of n Level = 0, next =
7 5 9 No room, so create an overflow block, which triggers the splitting process.
H1(4) = 00
h100011011
Insert using Linear Hashing
h001
4
H level (n) = level+1 bits of n Level = 0, next =
7 5
h100
10
Denotes split bucket
No room, so create an overflow block, which triggers the splitting process.
H1(4) = 00
9
Insert using Linear Hashing
h001
4
H level (n) = level+1 bits of n Level = 0, next =
7 5
Insert 8, h0(8) = 0
Advance NEXT by one.
h100
10
9
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
9
Insert using Linear Hashing
h001
4 8
H level (n) = level+1 bits of n Level = 0, next =
7 5No room, insert into overflow COULD trigger a split.
h100
10
9 3
Insert using Linear Hashing
h001
4 8
H level (n) = level+1 bits of n Level = 0, next =
5 9Redistribute 7, 5, 9, 3 using H1
H1(7) = 11H1(5) = 01H1(9) = 01H1(3) = 11
h100011011
7 3
Insert using Linear Hashing
h001
4 8
H level (n) = level+1 bits of n Level = 0, next =
5 9Advance Next, but it is at the bottom of the current Level.
h100011011
7 3
Insert using Linear Hashing
h001
4 8
H level (n) = level+1 bits of n Level = 1, next =
5 9So reset it to the top and increment Level to 1.
h100011011
7 3
Insert using Linear Hashing
4 8
H level (n) = level+1 bits of n Level = 1, next =
5 9Remove split indicators and only use H1
h100011011
7 3
Insert using Linear Hashing
4 8
H level (n) = level+1 bits of n Level = 1, next =
5 9
Insert 15, h1(15) = 11
h100011011
7 3
Insert using Linear Hashing
4 8
H level (n) = level+1 bits of n Level = 1, next =
5 9
h100011011
7 3 15No room, so create 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 9
h100011011
7 3 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 9
h100011011
7 3 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 9
h100011011
7 3 15
Mark bucket as splitAdvance Next.
4h2100
h2000
Insert using Linear Hashing
8
H level (n) = level+1 bits of n Level = 1, next =
5 9
h100011011
7 3 15
Mark bucket as splitAdvance Next.
4
And Insert and Insert and Insert ….
h2100
h2000