I have a C language application where I need to look up tables.
Entries are strings; they are all known at the beginning of execution. The table is initialized once, and then raised many times. The table may change, but basically as if the application is starting. I think this means that I can use the perfect hash? It is normal to use some time to initialize the hash table, as it happens only once.
There will be from 3 to 100,000 entries, each of which is unique, and I believe that 80% of cases will have less than 100 entries. In these cases, a simple, naive search is "fast enough." (== no one complains)
However, in cases where there are 10k + records, the search speed of the naive approach is unacceptable. What is a good approach to provide good hash table search performance for strings in C? Suppose I do not have a third-party commercial library such as Boost / etc. What hashing algorithm should I use? how can i decide
source share