Database Systems · Linear Hashing: Overflow Variant, Later-Round Splits and Search Cost
The problem linear hashing solves
Static hashing fixes the number of buckets . As the file grows, buckets overflow into chains and search cost degrades. Extendible hashing fixes this with a directory that doubles, but the directory is an extra indirection and can itself be large.
Linear hashing (Litwin, 1980) grows the file one bucket at a time, with no directory. It keeps a split pointer that sweeps left to right; when it reaches the end of the current bucket range, the range doubles and the pointer resets to 0.
Two variants exist:
| Variant | What triggers a split |
|---|---|
| Overflow-triggered (simple) linear hashing | A split is done whenever some bucket overflows (an insertion lands in a full bucket) |
| Load-factor-triggered linear hashing | A split is done whenever the load factor exceeds a threshold, wherever the overflow happened (keeps the load factor bounded) |
Many exam questions use the overflow-triggered variant, because it gives a deterministic insertion-by-insertion trace; always follow the trigger stated in the question. This chapter covers that variant.
Notation and the two hash functions
State the parameters first; every worked example below uses these symbols.
| Symbol | Meaning |
|---|---|
| Number of buckets at the start of the current round (a power of 2) | |
| Number of buckets currently in use, | |
| Split pointer: index of the next bucket to be split, | |
| Hash function used before a bucket is split | |
| Hash function used after a bucket is split | |
| Bucket capacity (records per bucket) |
The rule that decides the bucket of a key :
Why this works: is either or . A key with belongs to bucket while that bucket is not yet split (); once bucket has been split (), decides between bucket and bucket . The test is on , not on : a key that belongs to a new bucket has and would never pass the test .
Convention note (state this in your answer). Some texts (Elmasri–Navathe style) number buckets and write with the convention that remainder means bucket . Silberschatz-style and most GATE questions number buckets and use plain . Use 0-based unless the question's diagram is clearly 1-based; if 1-based, replace every "" by "". The arithmetic is identical, only the labels shift.
Round structure. A round begins with buckets, , . Each split adds one bucket at the end (index ), so grows by 1 and grows by 1. When reaches , the round ends: set , , and again (the file now has buckets, all addressed by the new ).
The overflow-triggered split procedure (exact steps)
insert(K):
1. compute target bucket t by the rule in section 2
2. if bucket t has a free slot: place K there; STOP
3. else: append K to the overflow chain of bucket t
4. perform ONE split:
a. allocate new bucket at index n
b. redistribute the records of bucket p (the split pointer bucket)
using h1 = K mod 2M: records with h1 = p stay in p,
records with h1 = p + M move to bucket n
c. p <- p + 1
d. if p = M: M <- 2M ; p <- 0 (round ends)
Two facts that exam questions test:
- The split is performed on bucket , not on the bucket that overflowed. The overflowed bucket keeps its chain until the pointer eventually reaches it.
- Only one split per insertion, even if the overflowed bucket is still full afterwards.