/Synthagram

C++

Primary LanguageMakefile

Synthagram

Synthagram is a console application that finds anagrams based on user input. Anagrams, in this context, are words that use the same characters as the user input. No character can be omitted, and the anagram words must exist in the dictionary.

Description of how it works as of version 1.1:

An instance of a dictionary class is created, and will serve as the basis for all other anagrams that can be considered words.

When the reference is created, it reads a text file containing valid dictionary words. For each word: The letters in the word are sorted alphabetically. The sorted sequence of letters becomes the key for the reference hash table/map. The original dictionary word is added to a vector. This is done to deal with hash table collisons. The sorted sequence of letters and the corresponding vector are inserted into the hash table as a pair. Doing this allows the look up of anagrams very fast ( O(log n) ).

Likewise, the user input string is also sorted alphabetically. The reference class then attempts to find a matching key in its hash table. If a matching key is found, its corresponding vector is returned, and its contents printed.