I’m implementing a hash table that will have no deletions. It, however, will have many checks to see if a key is contained, with many of the checks finding nothing. I was originally planning on some form of open addressing, because I was under the impression that open addressing is faster than separate chaining. Then it occurred to me that a find in open addressing would have to check every element to be sure something wasn’t there. Is this correct? If that’s so, would it be correct to think that separate chaining would be faster in the general case where you often need to check for membership?
Thank you!
If your hash-table is going to grow, even modestly, you can use a second hash to resolve collisions. Now your choice Open addressing Vs Chaining can be done on the second sub-table. You have to make sure that both hashs have as few collisions as possible.
Edit:
yes this is just another version of chaining, and some better variants are used in DB. Now whether it is relevant depends on what will be your system in the future. Just by intuition I agree that open addressing will reach its limits. You should look for different types of chaining