Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I must create a console autocomple app that uses a file with stats of each word:

paper 223
morning 114
motor 513
degree 22


There about 100000 words+

What is the best way (/algorithm) for doing that?

I am thinking of writing words of each first letter to a separate key-value List (SortedMap-TreeMap?) sorted by value and all of those lists would be inside an ArrayList. When a user types a word a corresponding list is searched for words that start with user-typed word and are displayed sorted by value. Is it a good approach?
Posted
Comments
Richard Deeming 25-Nov-15 11:10am    
Sounds like you need a Trie[^].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900