Algorithms and Data Structures: Trie (Prefix tree) 10 years ago
Not everyday I get to share this! I wrote some code in Go that uses a trie to quickly find anagrams. My trick is that I load the trie with a dictionary, but before I insert each word, I sort it alphabetically (ex: sort -> orst). Before I lookup a word I sort it alphabetically, so when I locate it in the trie, I also get all the other words that share the same characters. Because of the nature of the data structure, I can also quickly find all the smaller anagrams which will be handy when I get around to turning this into a full fledged scrabble playing AI: https://github.com/RyanEdwardHall/anagrambler