Trie (prefix tree)

medium

No node stores a word - a word exists when a path of edges spells it and ends on a node flagged as a word end. Shared prefixes cost nothing extra, which is what makes autocomplete cheap.

Worst O(length of the key)Space O(total characters × alphabet)
Loading the trie (prefix tree) engine…

Where to go next