Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h...

18
Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of n Level = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111, so h 0 (7) = 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...

Page 1: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 2: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

Insert using Linear Hashing

h001

4 2

H level (n) = level+1 bits of n Level = 0, next =

7

Insert 8, h0(8) = 0

Page 3: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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.

Page 4: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 5: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 6: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 7: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 8: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 9: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 10: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 11: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 12: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 13: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 14: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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.

Page 15: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 16: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 17: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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

Page 18: Insert using Linear Hashing h0 0 1 4 H level (n) = level+1 bits of nLevel = 0, next = 7 Insert 2, h 0 (2) = 0 initial 4 = 100, so h 0 (4) = 0 7 = 111,

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 ….