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 and integers take up p cells of memory, and that each record requires r cells of memory.

Open addressing requires Tr cells of memory

Coalesced chaining requires T(r+p) cells of memory (Tp more than open addressing)

Separate (external) chaining requires T(p + α(r+p)) = Tp + N(r+p) 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 r is much larger than p, 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 r and small α, open addressing performs well and saves memory. (Consider r near in value to p, or less than p.)

For some small r 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.