DeveloperHell | Languages: All | PHP | Python | .NET | Java | CSS | Ruby   Site: Statistics
want to join us? register, it's easy | help

browse by tag: algorithm in language

sort by

newest, oldest, most popular


category icon

Damn Cool Algorithms, Part 3: Anagram Trees

in Python added by admin, on 24/12/2007 algorithm general intermediate search tree

When it comes to finding anagrams of words, a frequent approach is to use an anagram dictionary - simply put, sort the letters in your word to provide a unique key that all anagrams of a word have in common. Another approach is to generate a letter-frequency histogram for each letter in your word. (Both these approaches are more or less equivalent, in fact.) These approaches make the problem of finding exact single-word anagrams for strings very efficient - O(1) if you use a hashtable.

comment save report