Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
Initial state:
Insert a
search key x that
has a hash value 0101
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
Since n=2 (# bits in hash value =
⌈log2(n)⌉ = 1),
we insert the search key in
bucket 1
Insert the
search key in the bucket...
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
Then we
check the
occupancy:
Occupancy =
4/(2 × 2) = 1.0
> τ (0.85) --
add a
physical bucket
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
We add physical bucket 10 (binary):
And we must re-hash
the search keys in
bucket Suffix-1( 10 (bin) ) =
0 (bin)
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
Re-hashing search keys
in bucket 0 (bin):
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
Final state -
insertion is
complete:
Next:
how do we
find
a search key x that has a
hash value 1111 ???
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
Since
n=2 (# bits in hash value
= ⌈log2(n)⌉ = 2),
we will use the
"virtual" bucket 11:
Because bucket 11 (bin) is
virtual, we will
use bucket[ Suffix(11) = 01 (bin)] !!
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
Example continues:
insert
a search key with
a hash value 0001:
Search key is
inserted in
a full disk block
→ use
overflow block !
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
After insertion, we
check
the occupancy...
Occupancy =
5/(3 × 2) = 0.8333
≤ 0.85 --
done ! ---
Next:
insert 1011...
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
Next:
insert 1011:
since
n=2 (# bits in hash value
= ⌈log2(n)⌉ = 2),
we will use the
"virtual" bucket 11:
Because bucket 11 (bin) is
virtual, we will
use bucket[ Suffix(11) = 01 (bin)] ---
insert in
bucket 01 (bin).
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
After
inserting 1011:
Check occupancy:
6/(3 × 2) = 1
> τ (0.85)
→
add a
bucket !
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
We add the
physical bucket 11 (bin):
And we must re-hash
the search keys in
the bucket[ Suffix-1 (
11 (bin) )
= 01 (bin)]
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
Re-hashing
the search keys in
the bucket[ Suffix-1 (
11 (bin) )
= 01 (bin)]:
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
After the
re-hash operation is
completed:
We can
optionally compact the
bucket[ Suffix-1 (
11 (bin) )
= 01 (bin)]...
Example Linear Hashing with
# keys/block γ = 2 and
threshold τ = 0.85
If we compact:
❮
❯