I am currently reading the CLRS book and looking at how hashtables are defined there, when talking about open hashing and using chaining for collision resolution there is a piece of text that reads:
If the hash table supports deletion, then its linked lists should be doubly linked
so that we can delete an item quickly. If the lists were only singly linked, then to
delete element x, we would first have to find x in the list T[h(x.key)] so that we
could update the next attribute of x’s predecessor. With singly linked lists, both
deletion and searching would have the same asymptotic running times.)
What I dont understand is why this is the case (or more specifically how), this is not a question about why deleting from a linked list when you know the element is faster if its a doubly linked list, I thought I should make that clear...
This is related to how it is possible to actually know the location, and so a doubly linked list can make this difference because looking at the hash delete pseudocode (below) the key is used to generate the hash which leads to the correct array index of where the linked list can be found but how exactly can that be translated into the actual position in the linked list of the item?
CHAINED-HASH-DELETE(T, x)
1 delete x from the list T[h(x.key)]
It looks to me like hashing the key leads to the linked list only, so in either case the list would still need to be searched to find the actual value currently being deleted?
Im sure there is a simple answer but it is just not clear to me!