Trie (prefix tree)
mediumNo 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…