I'm trying to implement a method that will store all words in a Trie data structure in a List.
This is my Node class:
I am using a HashMap to store the child characters as keys and the child nodes as values. A node that completes a
word will have the field isCompleteWord set to true.
Methods to add all words to a List:
Currently if I have stored in the Trie the words "beard", "bold", "brew", when I print the list of words starting with the prefix "b", I get:
What I was expecting:
I think I need a way for the
String word to be reset whenever I have found a word, instead of the next characters being appended.