I'm doing a project in which I have to search for a word in a dictionary efficiently. Can any one provide me the Java code for implementing this search with indexing?
Can I use a b+ tree for the implementation?
I'm doing a project in which I have to search for a word in a dictionary efficiently. Can any one provide me the Java code for implementing this search with indexing?
Can I use a b+ tree for the implementation?
Check out this answer.
The best way I know of (personally) to efficiently map from strings to other values is with a Trie. The answer I provided includes links to several already implemented versions.
An alternative is interning all your strings and indexing based on the yourString.intern().getHashCode()
.
This sounds like homework. If it is, please tag it as such.
Is "using an index" an external requirement, or one you've invented because you think it's part of the solution?
I would consider using a datastructure called a "Trie" for this kind of requirement (assuming the use of an index isn't actually mandated - although even then, you could argue that the Trie IS the index...)