I am writing a dictionary kind of application in java.I have a list of 2.5 million words lookup list in a word document.My dictionary is based on a mobile application.So when the user types 4 I should get words starting with letter namely ghi and for if i type 2 I should take letters starting with ghi and second letter is one of abc.
Now what should be the approach to be followed.
1. What should be the datastructure to store the list of words based on space and time complexity?
2.I am confused because if I type 15 digits its almost mindboggling combination to do a brute force check after all the digits are typed.So I should take words starting with ,contains these.
Can anyone guide me?
Well, first of all you normalize your words by replacing each letter with the corresponding key (e.g. replace every
g,handiwith4and so on). You then construct a trie or some other prefix data structure to store words based on their nomalized representation. The rest is easy.