Overview
A Trie represents each key as a path of characters or tokens from the root. Shared prefixes occupy shared nodes, making prefix queries natural.
Stores strings by sharing prefixes along paths through a tree.
Compact metadata for implementation and discovery.
A Trie represents each key as a path of characters or tokens from the root. Shared prefixes occupy shared nodes, making prefix queries natural.
Quick facts
Runtime and memory behavior at a glance.
Best
O(m)
Average
O(m)
Worst
O(m)
Space
O(nm)
Show words branching only when their prefixes differ.
Tries make prefix operations efficient at the cost of extra pointer or map overhead.
What each reference supports for this entry.
Algorithms textbook support for Trie's data-structure operations and practical implementation model.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Pattern Matching · Core
Aho-Corasick builds a pattern trie before adding failure links.
Compare with thisData Structures · Core
Both can support dictionary-like lookup, but BK-trees organize items by metric distance.
Compare with thisData Structures · Core
Both store strings through shared-prefix tree structure.
Compare with thisAho-Corasick builds a pattern trie before adding failure links.
Both store strings through shared-prefix tree structure.