Background:
I am writing an application for a small embedded device. There is a static list of strings: currently about 500 strings and string length is 12 characters on average. The list might increase in the future. When the application starts running, the list of strings will be parsed once. No more additions, deletions to the list. The search() will be called large number of times.
I need to find if a input string is in the list. Currently, I am sorting and storing the strings in an array. I am using binary search to find the string. Worst case is 0(log n) and space complexity is 0(12*n) (??).
Question:
Is there a better approach? I know hash tables are faster. But I am concerned about extra memory. I can create a hash table of size n. But I would need a Perfect hash function. Any suggestions on how to come up with such a hash function? Is it just trial and error? Any other data structure that could be better?