I'm not really a data structures guy, but I love anagrams. When i wrote the anagramica API, the simplest way that I could come up with a fast search was this:
- Take a word and sort its characters.
- Add it to a dictionary where the key is the sorted characters and the value is the word.
- If the sorted characters already exist in the dictionary then add it to the list of words for the same key.
This gives O(log n) when you give it a list of letters and you need to find all the possible words.What benefits do GADDAG offer over the above?