I need to make a program that counts frequency of each word in a text, additionally I need to be able to return a list of n most often words(if more words have same frequency they are sorted alphabetically). Also there is a list of words that are not counted (Stop words).
- What structure to use for the stop words
- I think that HashSet would be most efficient
- What structure to use for the words and frequency mapping
- HashMap would be more efficient for adding words, but would require sorting, TreeMap requires logn time for inserting words, but words can be sorted by frequency
What approach overall is more efficient?
P.S. @Moderators I know there is a similar question, but I have a different constrains that require a different structure.