Aryan PrajapatKnowledge Contributor
Could you provide some implementation of a Dictionary having a large number of words in java?
Could you provide some implementation of a Dictionary having a large number of words in java?
The simplest implementation that can be given is that of a List wherein one can place ordered words and perform a Binary search. The other implementation with a better search performance is HashMap where the key is used as the first character of the word and the value as a LinkedList.
Up another level, there are HashMaps like:
hashmap {
a (key) -> hashmap (key-aa , value (hashmap(key-aaa,value)
b (key) -> hashmap (key-ba , value (hashmap(key-baa,value)
z (key) -> hashmap (key-za , value (hashmap(key-zaa,value)
}
Up to n levels where n is the average size of the word in the dictionary.