Why does a hash table with linear probing need a “no object” value or a parallel array of Boolean? Give an example of the problem that can happen if we have neither of these techniques? Which technique is more space efficient? Why?
1 Answer
Ask yourself this: What happens when we delete an item from a hashtable? If at some point when we inserted an element into the hashtable that caused a collision, we would have to linearly probe to find a better spot, but if we delete the original item and don't leave a marker we'll never be able to find the new item again.
As to which one is more efficient, generally leaving a "no object" value is the best, because the space has to be taken up any way so we might as well use it for something rather than allocating a whole new array to keep track of what memory is useless in the hashtable.