ashmish2
ashmish2

Reputation: 2967

preprocessing dictionary

How to preprocess dictionary so that below operations are best supported a) search in dictiorry b) given a string find all valid anagrams in a dictionary c) typing prefix of a valid string suggests valid words

Will trie do the trick?

Upvotes: 0

Views: 280

Answers (1)

Karl Knechtel
Karl Knechtel

Reputation: 61635

For (a) and (c), use an ordinary trie. For (b), sort each word, and build a trie with the sorted words, but associate each leaf in the trie with a list of the (un-sorted) words that correspond to it.

Upvotes: 3

Related Questions