I'm implementing a closed-hashing class.
I'm trying to find a strategy that will solve the scenario when two elements a and b have the same hash value, I want to search a null place for b which is not a. My trivial solution is to try to go over all of the elements next to a till the end of the table and if I get to the end without finding a null place I'll go to the beginning of the table and go over all of the elements till I reach which will indicate that the table is full. This solution has a running time of O(n) and I need to do it by O(1)
Can you help me please find a solution?
Thanks in advance!