Jumble

The class Jumble implements the first algorithm discussed here. The program begins by building a static Map of dictionary entries. The key for each entry is a sorted string of the characters comprising the word. The value is a Set of words that include only those letters. Once the dictionary is built, checking a word proceeds very quickly: The word's characters are sorted, O(n log n), and the sorted string is used to look up the corresponding Set of words in the Map. The lookup itself offers O(1) performance.

Ada implementations of both algorithms may be found here.

Copyright © 2008 John B. Matthews. Distributed under the terms of the GPL