Hi all,

I have givn a task to implement a game.
It has ruls of texa's Holdem poker and the objective is to
make words like scabble.So it is a blend of these 2 games.

So i need to store (Only with 5 letters)words(I dont know whether it is a trie,database,map or what..).
There are about 20,000 words.
What i want do is:
When im providing 2 letters(ex: a,c) the storage should give me all the words
which contains a and c.

PLZ some one give me a way of doing this.
I feel like store all the words in a text file and retrieve word by word and use regular expresssion.
Will it be good in performance wice?
Or give me a better idea of doing this.

Thnx in advance.

Edited by coroll

4 Years
Discussion Span
Last Post by JamesCherrill

For that size of data there's no reason why you would not keep it all in memory - about a megabyte should be enough. You can simply read a text file with all the words into an array of Strings. Searching in memory will be orders of magnitude faster than searching a file, and a lot easier as well.
Looping through 20,000 strings testing for particular characters shouldn't take too long relative to human timescales, but it would be a good idea to define a method that just does the searching so that it's easy to try different solutions to implement the method without needing to change any other parts of the program (eg regex vs checking the characters with simple if tests vs clever indexing schemes).


The requirements for the project was changed. Now I have 51947 words.

And i want get all the words when i provide a set of letters.
Ex: abanana

Is it still ok to load the words into an array and do this search.
Or is it better to implement a trie?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.