180 likes | 266 Views
4. 7. Insert using Linear Hashing. H level (n) = level+1 bits of n. Level = 0, next =. h0 0 1. initial. Insert 2, h 0 (2) = 0. 4 2. 7. Insert using Linear Hashing. H level (n) = level+1 bits of n. Level = 0, next =. h0 0 1. Insert 8, h 0 (8) = 0. 4 2. 7. 8.
E N D
4 7 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 0, next = h0 0 1 initial Insert 2, h0(2) = 0
4 2 7 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 0, next = h0 0 1 Insert 8, h0(8) = 0
4 2 7 8 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 0, next = h0 0 1 No room, so insert into an overflow block, which triggers the splitting process.
4 2 7 8 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 0, next = h1 00 01 10 11 h0 0 1 No room, so insert into an overflow block, which triggers the splitting process. H1(4) = 00 H1(2) = 10 H1(8) = 00
4 8 7 2 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 0, next = h1 00 10 h0 0 1 Denotes split bucket No room, so insert into an overflow block, which triggers the splitting process. H1(4) = 00 H1(2) = 10 H1(8) = 00
4 8 7 2 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 0, next = h1 00 10 h0 0 1 Advance NEXT by one. Insert 5, h0(5) = 1
4 8 7 5 2 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 0, next = h1 00 10 h0 0 1 Insert 3, h0(3) = 1
4 8 7 5 2 3 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 0, next = h1 00 10 h0 0 1 No room, insert into overflow and trigger a split.
4 8 5 2 3 7 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 0, next = h1 00 01 10 11 h0 0 1 Redistribute 3, 5, 7 using H1 H1(3) = 11 H1(5) = 01 H1(7) = 11
4 8 5 2 3 7 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 0, next = h1 00 01 10 11 h0 0 1 Advance Next, but it is at the bottom of the current Level.
4 8 5 2 3 7 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 h0 0 1 So reset it to the top and increment Level to 1.
4 8 5 2 3 7 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 Remove split indicators and only use H1
4 8 5 2 3 7 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 Insert 15, h1(15) = 11
4 8 5 2 3 7 15 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 No room, so insert into an overflow block, which triggers the splitting process.
4 8 5 2 3 7 15 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 Split Next using level+1 H function H2(4) = 100 H2(8) = 000
8 5 2 3 7 15 4 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 Split Next using level+1 H function H2(4) = 100 H2(8) = 000 h2 100
8 5 2 3 7 15 4 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 Mark bucket as split Advance Next. h2 100
8 5 2 3 7 15 4 Insert using Linear Hashing H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 Mark bucket as split Advance Next. h2 100 And Insert and Insert and Insert ….