Presentation is loading. Please wait.

Presentation is loading. Please wait.

Insert using Linear Hashing

Similar presentations


Presentation on theme: "Insert using Linear Hashing"— Presentation transcript:

1 Insert using Linear Hashing
H level (n) = level+1 right most bits of n Level = 0, next = h0 1 4 4 = 100, so h0(4) = 0 7 = 111, so h0(7) = 1 7 initial Insert 5, h0(5) = 1

2 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 0, next = h0 1 4 Insert 9, h0(9) = 1

3 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 0, next = h0 1 4 No room, so create an overflow block, which triggers the splitting process. 9

4 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 0, next = h1 00 01 10 11 h0 1 4 No room, so create an overflow block, which triggers the splitting process. H1(4) = 00 9

5 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 0, next = h1 00 10 h0 1 4 Denotes split bucket No room, so create an overflow block, which triggers the splitting process. H1(4) = 00 9

6 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 0, next = h1 00 10 h0 1 4 Advance NEXT by one. 9 Insert 8, h0(8) = 0

7 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 0, next = h1 00 10 h0 1 9 Insert 3, h0(3) = 1

8 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 0, next = h1 00 10 h0 1 No room, insert into overflow COULD trigger a split.

9 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 0, next = h1 00 01 10 11 h0 1 Redistribute 7, 5, 9, 3 using H1 H1(7) = 11 H1(5) = 01 H1(9) = 01 H1(3) = 11

10 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 0, next = h1 00 01 10 11 h0 1 Advance Next, but it is at the bottom of the current Level.

11 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 h0 1 So reset it to the top and increment Level to 1.

12 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

13 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

14 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 No room, so create an overflow block, which triggers the splitting process. 15

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 15

16 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 h2 000 8 Split Next using level+1 H function H2(4) = 100 H2(8) = 000 15 h2 100 4

17 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 h2 000 8 Mark bucket as split Advance Next. 15 h2 100 4

18 Insert using Linear Hashing
H level (n) = level+1 bits of n Level = 1, next = h1 00 01 10 11 h2 000 8 Mark bucket as split Advance Next. 15 h2 100 4 And Insert and Insert and Insert ….


Download ppt "Insert using Linear Hashing"

Similar presentations


Ads by Google