Memory Requirements of Hashing
T = the table size = the number of slots in the hash table (We
assume that in the case of open addressing or coalesced chaining,
a table slot holds 1 record. In the case of external chaining a
table slot holds just one pointer.)
N = number of records stored in the hash table
α = N/T = the load factor
assume that pointers take up 1 cell of memory, and that each
record requires w cells of memory.
Open addressing requires Tw cells of memory
Coalesced chaining requires T(w+1) cells of memory (T more than
open addressing)
Separate (external) chaining requires T(1 + α(w+1)) = T + N(w+1)
cells of memory.
In the case of separate chaining each record stored in the table
requires a node containing the record plus a pointer.
If w is large, external chaining has good performance and close
to minimum memory requirements. External chaining is also useful
when the maximum table size cannot be gauged in advance.
For small w and small α, open addressing performs well and
saves memory.
For some small w and some larger α, open addressing gets to be
inefficient but coalesced chaining continues to work efficiently
and uses less memory than external chaining.
Note that hashing is for larger sets - sets of less than 300 or
so elements should be handled with binary search.