Database Systems · Static Hashing for Files
Overflow Handling
Overflow happens when more than 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 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 is full, probe a fixed sequence of other buckets until a free slot is found:
-
Linear probing: try
-
Quadratic probing: try
-
Double hashing: step size , i.e. try
-
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
| Criterion | Chaining (overflow linked list) | Open addressing (linear/quadratic/double) |
|---|---|---|
| Extra space | Pointer per bucket + overflow blocks | None (uses empty slots in the table) |
| Max records | Unlimited (overflow grows) | At most (table can fill completely) |
| Search when high | Degrades gracefully (chain length grows) | Degrades sharply; fails if table full |
| Clustering problem | None across different home buckets | Primary clustering (linear), secondary (quadratic) |
| Deletion | Easy (unlink) | Needs tombstones / rehash |
| Typical DBMS file use | Yes — standard for disk files | Rare on disk (cache-friendly in memory) |
| GATE default | Assumed unless stated otherwise | Stated 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.