Definition
Compressed Trie
A compressed trie represents the same set of strings as a trie, but removes every non-root, non-terminal node with exactly one child. Each resulting chain becomes one edge whose label concatenates the original labels:
The root, branching nodes, and terminal nodes remain. Edges carry non-empty strings, and outgoing edges still have distinct first characters. Reading a root-to-node path spells the same string before and after compression; membership still requires ending at a terminal node.
In the diagram,
a,b, andbadisappear, butanremains because it is stored. Compression shortens paths in edges, not in characters: an edge labelledbarstill requires checking three characters.
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.