Trie

Trie is a tree-based data structure for sorting strings in order to support fast pattern matching.

The exact string matching algorithms all try to pre-processing the pattern string, while the algorithms using trie use a different approach and try to to pre-processing the text string (if the text string(s) is relatively fixed and the matching needs to be performed many times with different pattern strings).

Trie can be used to perform both exact string matching and prefix matching.

Main application of trie: information retrieval (especially search engine indexing) and Lempel-Ziv encoding.

There are two types of tries: standard trie, and compressed trie.

To construct a trie, a set of strings (S) from a finite alphabet Σ is given, and no string in the set is the prefix of another string in the set.

A standard trie is an ordered tree with the following properties:

A compressed trie is a trie that compresses redundant nodes (the nodes with exactly one child node) together.

A suffix trie is a trie that is constructed using one string. The set of the strings are the suffix strings of the given string. Both standard trie and compressed trie can be used to construct the suffix trie.