next up previous index
Next: Choice of hash function Up: Hash Tables Previous: Performance   Index

Removal

The open addressing method does not lend itself very easily to simple removal of an item from the table. The reason is that the location of items inserted later than the item to be removed, would not have been inserted where they are, if that item had not been present at the time. The simplest solution is to use ``lazy'' deletion by simply marking an item to be removed as deleted. This requires an extra field in the hash entry. Deleted items are simply walked past when searching the table. When inserting a new item, a deleted entry is treated as though it were null. Thus deleted entries become overwritten by new entries as soon as possible.

This way of dealing with removal of items from a hash table makes for certain inefficiencies. These are not significant if removal occurs only rarely. If removals are common, it may be better to use an alternative to open addressing as a strategy for collision resolution.

When it comes to implementing probing hash tables, the effective size of the table must be counted as the sum of the number of current entries and the number of deleted entries. When a new entry is to be inserted, this is the relevant count in relation to efficiency, as determined by the loadFactor, as well as effectiveness, i.e. whether a new entry can be added at all.


next up previous index
Next: Choice of hash function Up: Hash Tables Previous: Performance   Index
Peter Williams 2005-06-07