I am learning hash table in python and one question occurs here.
when hash function begins , I should generate a empty "map" hash the list.But why "nonempty slot already contains the key ,the odd data value is replaced with the new data value", isn't it should find the next empty slot and store there,why replace ?
https://interactivepython.org/runestone/static/pythonds/SortSearch/Hashing.html
hashfunction implements the simple remainder method. The collision resolution technique is linear probing with a “plus 1” rehash function. The put function (see Listing 3) assumes that there will eventually be an empty slot unless the key is already present in the self.slots. It computes the original hash value and if that slot is not empty, iterates the rehash function until an empty slot occurs. If a nonempty slot already contains the key, the old data value is replaced with the new data value. Dealing with the situation where there are no empty slots left is an exercise.