• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about efficient data structure for my problem  RSS feed

 
pandu chinnu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

Iam developing a complete application for the first time. It is a document processor giving out word counts, Words with more than 'x' characters in length, frequency of words in a document, word search(tells if a word is available or not and if available then gives its frequency).

My question is how do I decide the best data structure to be used for this problem.I believe as words are involved, speed would be a critical issue for large documents. Can someone suggest candidate datastructures and why one might be better than the rest for this problem.Or is it better to use more than 1 data structure?

Thanks
 
Jeremy Botha
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Pandu.

Given that you're trying to relate word counts, the first thing I'd suggest is a Map object, keyed by the word of interest, and containing a Integer or Long as the value.

Maps are generally the most efficient way to store data when you need quick access by key. You can probably find a faster method with Google, but the sort of speedup you might gain will be counteracted by much greater complexity.

Jeremy
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would also suggest a Map. Use the words as the keys and the store the other details in data object(which could have the frequency etc.). If it's just the frequency you can have the frequency as the value in Map.
[ July 09, 2007: Message edited by: Anupam Sinha ]
 
pandu chinnu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the suggestion, however I am not too familiar with maps.I was thinking of using Lists. Can you guide me if List would be fine or direct me where I can learn basics about maps.(Urls or other resources)
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are a few possible resources:

The sun documentation (J2SE 5.0) for the Map interface.

The sun documentation (J2SE 5.0) for the HashMap class.

Some example code using HashMap and TreeMap.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!