Now I have this question when I was asked the cost of deleting a value from a hash table, when we used linear probing during the insertion process.
What I can understand from reading various materials on the Internet is that he has to do something with a load factor. Although I'm not sure, but I read the relationship between the load factor and the lack of probes, and this is No of probes = 1 / (1-LF).
So, I believe that the cost should depend on the sequence of probes. But then another thought destroys everything.
What if the element was inserted into p probes, and now I'm trying to delete this element. But before that, I had already deleted several elements that had the same hash code, and was part of the insertion into the samples less than p.
In this case, I get to the stage where I see the slot empty in the hash table, but I'm not sure that the item I'm trying to delete is already deleted or is in some other place as a result of the check.
I also found that as soon as I delete an item, I should mark this slot with a special indicator to indicate that it is available, but this does not solve my problem of the uncertainty of the item that I am ready to remove.
Can anyone suggest how to find value in such cases? Will this approach change if it is non-linear sounding?
source
share