Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to search for a given word from a huge database?

What's the most efficient method to search for a word from a dictionary database. I searched for the answer and people had suggested to use trie data structure. But the strategy for creating the tree for a huge amount of words would be to load the primary memory. I am trying to make an android app which involves this implementation for my data structure project. So could anyone tell me how do the dictionary work.

Even when I use the t9 dictionary in my phone, the suggestions for words appear very quickly on the screen. Curious to know the algorithm and the design behind it.

like image 552
Ashwin Surana Avatar asked Mar 19 '13 08:03

Ashwin Surana


People also ask

Which of the following allow you to quickly search record in a large database?

Indexing is a data structure technique that allows you to quickly retrieve records from a database file.

Which data structure is used for fast searches in extremely large dataset?

you're probably talking about a hash table, or "hash map" as known on some libraries.


1 Answers

You can use Trie which is most usefull for searching big dictionaries. Because too many words are using similar startup, trie brgins around constant factor search also you can use in place, with limited number of access to physical memory. You can find lots of implementation in the web.

If someone is not familiar with trie, I think this site is good and I'm just quoting their sample here:

A trie (from retrieval), is a multi-way tree structure useful for storing strings over an alphabet. It has been used to store large dictionaries of English (say) words in spelling-checking programs and in natural-language "understanding" programs. Given the data:

an, ant, all, allot, alloy, aloe, are, ate, be 

the corresponding trie would be: Sample Trie for above words

This is good practical Trie implementation in java: http://code.google.com/p/google-collections/issues/detail?id=5

like image 159
Saeed Amiri Avatar answered Sep 28 '22 18:09

Saeed Amiri