Hai all,

I'm being create a dictionary. In the dictionary have feature search the word. if user entering the character "g" the word view in JList will show the word begin with "g". i try this first using Linier Search, it found the word, but linier. i mean if i input the "g" the view not show the word with begin "g", but i must type the next character to find the exact word. but i want if the user input g, the related word that begin with g will show for the first in JList. below i put my screenshoot. the first is when i open the sample dictionary and the second image if i enter the g the list will change to view the word begin with g. How can i create the search like that?please help me!!.

Best Regards

The simplest solution would be to use the "startsWith" method of the String class and inspect each and every dictionary entry whether it starts with the user input. But this approach can become unwieldy if the dictionary has a *lot* of entries since it means scanning the entire dictionary for every character entered by the user. Look into the "trie" data structure which is meant for exactly these kind of use cases if the "startsWith" solution doesn't suit your needs.

The simplest solution would be to use the "startsWith" method of the String class and inspect each and every dictionary entry whether it starts with the user input. But this approach can become unwieldy if the dictionary has a *lot* of entries since it means scanning the entire dictionary for every character entered by the user. Look into the "trie" data structure which is meant for exactly these kind of use cases if the "startsWith" solution doesn't suit your needs.

I have success create the search, using ternary search algorithm. but, not complete. still some bugs. the bugs is there is no traversal tree algorithm when user input the textfield, it cause i'm confused how to create it?. maybe you can help me to find out the problem. here is, i include my source code. you can try to find out the problem and me to. if you find the solution please, tell me.

Thanks a lot