I've seen a thread or two on this already, but I still don't think it's been fully cleared up so...
I've been looking at hash tables with chaining in Introduction to Algorithms (Chapter 11). They say that if a hash table's linked lists are doubly-linked then deletion can be preformed in O(1) time. But I can't see how so.
T is a chained hash table. I want to delete element X from it.
h(X.key) returns the hash of X's key.
So, to delete X, pass X to the delete routine.
Then we can find X's slot in the linked list:
T[ h(X.key) ] = j
j is actually the pointer to the head of the linked list as > 1 key hashes to j.
So we still need to now search the linked list at j to find X to delete it,
regardless of whether or not the list is doubly linked.
And this search is O(n). So deletion is O(n)???
My point is that don't we still need to search the linked list for X? X is an arbitrary object that we want to store in a hash table. It does not contain pointers. The element in the linked list that holds X will contain pointers to the next and previous elements in the linked list, but not X.