Ashwin Surana
Ashwin Surana

Reputation: 876

How to design dictionary app using trie?

I have planned to use trie data structure implementation in dictionary application, but the problem is loading more than 10,000 words into the trie. Though trie takes out redundancy of letters and total memory loaded in primay would nothing more than couple of kbs but still the time required for loading all the words into the trie would take a lot of time nwould take even more if it's implemented for a mobile phone app..

Any suggestions of what could be done?

Upvotes: 0

Views: 483

Answers (1)

cyon
cyon

Reputation: 9538

Instead of (or maybe in addition to) shipping a database containing a dictionary along with your app, you could ship a serialized trie containing all the dictionary words. This could be serialized in any way you want (perhaps as a blob in a database or xml file) and you could then deserialize it to create a java trie object when the app starts up.

To do this you could use a deploy script which creates the trie by going through all dicitionary words, places them into the trie and then serializes the trie into some file or blob and packages this serialized trie with the released app.

Upvotes: 1

Related Questions