0

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?

zengr
  • 38,346
  • 37
  • 130
  • 192
Jeevi
  • 2,962
  • 6
  • 39
  • 60
  • People here are usually happy to help anyone who comes along, but I'll warn you, Stack Overflowers are notoriously grumpy when people ask, "can anyone provide me code for ____". Many of us are paid to write code, and writing code for someone else for free is a waste of time. That said, helping people fix their bad code, or answering specific questions (Like your B+ Tree question) is beneficial to everyone, and people are pleased to write code samples and such. Could you, perhaps, rephrase your question a bit? – Chris Pfohl Mar 02 '11 at 19:02
  • A trie is the best solution for implementing a dictionary. – zengr Mar 02 '11 at 19:06

2 Answers2

1

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().

Community
  • 1
  • 1
Chris Pfohl
  • 18,220
  • 9
  • 68
  • 111
0

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...)

dty
  • 18,795
  • 6
  • 56
  • 82