data-structures string-algorithms
Definition
Compressed Trie
Examples
Word membership
Let
The string is in because it follows the edge labels
and ends in a terminal node. The string is not in if the node for is not terminal, even though it is a shared prefix of and .
Preserving stored prefixes
If , then the node for must remain terminal. The compressed trie may contain an edge labelled from the root and then an edge labelled to .
Thus, compression removes only non-terminal one-child nodes. It does not hide a stored string that is a prefix of another stored string.
Suffix trees
A suffix tree can be viewed as a compressed trie built from all suffixes of one string, usually after adding a fresh letter so that no suffix is a prefix of another suffix.