Search code examples
hashtable

Search in Linear addressing - Hash tables


The definition of search function in linear addressing according to geeksforgeeks.org website is :

Search(k): Keep probing until slot’s key doesn’t become equal to k or an empty slot is reached.

This statement says that we stop searching once until slot's key doesn't become equal to k ? But in linear probing, we keep probing linearly until we reach the end of the cluster even if we have "scanned" many slot's with keys doesn't equal to the required k ?


Solution

  • That looks like an error to me. In linear probing, you hash to some initial location, then scan forward until you either find the element you’re looking for (k) or hit an empty slot. There’s sometimes a third condition considered for the edge case where the table fills up, and that’s to stop once you’ve scanned every slot in the table.