Two cases exist:
1. If
, then only one entry in the bucket address table
points to bucket
.
- Then we need to increase the size of the bucket address table so that
we can include pointers to the two buckets that result from splitting
bucket
.
- We increment
by one, thus considering more of the hash, and
doubling the size of the bucket address table.
- Each entry is replaced by two entries, each containing original value.
- Now two entries in bucket address table point to bucket j.
- We allocate a new bucket
, and set the second pointer to point to
.
- Set
and
to
.
- Rehash all records in bucket
which are put in either
or
.
- Now insert new record.
- It is remotely possible, but unlikely, that the new hash will still
put all of the records in one bucket.
- If so, split again and increment
again.
2. If
, then more than one entry in the bucket address table
points to bucket
.
- Then we can split bucket
without increasing the size of the
bucket address table (why?).
- Note that all entries that point to bucket
correspond to hash
prefixes that have the same value on the leftmost
bits.
- We allocate a new bucket
, and set
and
to the
original
value plus 1.
- Now adjust entries in the bucket address table that previously
pointed to bucket
.
- Leave the first half pointing to bucket
, and make the rest
point to bucket
.
- Rehash each record in bucket
as before.
- Reattempt new insert.