I'm writing a program that will be able to solve word puzzles. Essentially I'm taking in a dictionary through an Infile.txt and creating a Hash table with it. I'm going to use separate chaining, and the java LinkedList class as the second level of the hash table (using a simple array that will point to linked lists). Feel free to suggest a better solution, as I am a novice data structurer. After taking in the dictionary I will be searching the hash table for words against a list of jumbled strings from an infile. I'm not worried about the searching at this point.
The dictionary is 109530
in size. That is the constant size of the input data. What would you say is the best size for the hash table? I've read conflicting things about this so I thought I'd ask here, so please explain your reasoning a bit.
Lastly, I'm going to use the following function as the hash function:
Hash(string) = ( SumOf(AsciiValOfChar() * CharPosInString()) ) mod TableSize;
Example: the string "abc" will be 97(ascii value of 'a') * 1 + 98 * 2 + 99 * 3 mod tablesize
.
So if table size is 10
"abc" will = 0 = 590 mod 0
.
Any thoughts about this hash function?
Thanks a lot guys, your time is highly appreciated.
EDIT: I'm not using the Java hastable / hashmap class, rather I need to write my own. This is an exercise.