1. Gyanastra
  2. Database Systems
  3. Static Hashing for Files
  4. Overflow Handling
Free lesson, no account needed 4 min read

Database Systems · Static Hashing for Files

Overflow Handling

Overflow happens when more than RR records hash to the same bucket. Two families of fixes:

4.1 Chaining (overflow chaining)

Terminology warning. Silberschatz–Korth–Sudarshan call overflow chaining closed hashing and probing open hashing; data-structures texts use the two names the other way round. Do not rely on the labels; use "chaining" and "probing". Each bucket keeps a pointer to a linked list of overflow blocks. All records that hash to bucket aa but don't fit live in that chain.

Bucket array (B buckets)          Overflow area
+--------+
| 0      | [rec][rec]  (full)
+--------+
| 1      | [rec]
+--------+
| 2      | [rec][rec]- [rec][rec]- [rec]   <- overflow chain
+--------+
| ...    |
+--------+
| B-1    | [rec]
+--------+
  • Search cost = 1 (home bucket) + number of overflow blocks scanned.
  • Simple, no clustering of other keys, deletion is easy (unlink).

4.2 Open addressing (probing)

No pointers. If bucket aa is full, probe a fixed sequence of other buckets until a free slot is found:

  • Linear probing: try a,(a+1) mod B,(a+2) mod B,…a, (a+1)\bmod B, (a+2)\bmod B, \dots

  • Quadratic probing: try a,a+12,a+22,…(modB)a, a+1^2, a+2^2, \dots \pmod B

  • Double hashing: step size =h2(k)= h_2(k), i.e. try a,(a+h2(k)) mod B,…a, (a+h_2(k))\bmod B, \dots

  • Search must replay the same probe sequence and stop at the first empty slot (record absent) or when the key is found.

  • Primary clustering (linear probing): long runs of occupied buckets form, slowing every search that lands in the run.

  • Deletion is tricky: you cannot simply empty a slot (it would break probe chains) — you need a "tombstone/deleted" marker.

4.3 Comparison table

CriterionChaining (overflow linked list)Open addressing (linear/quadratic/double)
Extra spacePointer per bucket + overflow blocksNone (uses empty slots in the table)
Max recordsUnlimited (overflow grows)At most B×RB \times R (table can fill completely)
Search when α\alpha highDegrades gracefully (chain length grows)Degrades sharply; fails if table full
Clustering problemNone across different home bucketsPrimary clustering (linear), secondary (quadratic)
DeletionEasy (unlink)Needs tombstones / rehash
Typical DBMS file useYes — standard for disk filesRare on disk (cache-friendly in memory)
GATE defaultAssumed unless stated otherwiseStated explicitly ("linear probing")

Which does GATE mean? If a question says only "overflow" or "overflow blocks/chaining", assume chaining. If it says "linear probing" or "open addressing", use probing. Never mix the two in one calculation.


Pages 1–2 of 2