Which data structures should I use to implement a trie in Java?
Do I use a linked list, array, map?
Which data structures should I use to implement a trie in Java?
Do I use a linked list, array, map?
The way I implemented a Trie was to use a custom class for the node and store outgoing links as either a HashMap or ArrayList (depending on the number of child nodes).
The reason to split the two cases was that many of the nodes would have just a few child nodes and using a Map would actually slow things down. If I recall correctly I put the limit at about 4 child nodes.