Hello, I was wondering what would be the most efficient implementation of a dictionary (to store words and something about them), given that the most important feature is word lookup speed (ideally constant time).
My first thought was a hash table, but I have no idea what the hash function should be or how to implement a hash table. Is this a good implementation? if so, what would be a good hash function?
Any thoughts or suggestions would be greatly appreciated!
An easy way is using a std::map ( http://www.cplusplus.com/reference/stl/map/ ), it isn't a true hash table but it's easy to use.
The lookup speed (according to the reference page) is logarithmic
Thanks for your help! I definitely want to use a hash map, since we need to look up words incredibly fast and do not want the log(n) factor (n is large).
To build this, I think I need a hash function which will take a word, and give me an index in an array containing the definitions (actually some other value). I am confused on what hash function will be useful; and how the has map will initially assign locations in the array. Any tutorials or suggestions on how to build hash maps?