C/C++ Arena

Step 6 of 6

Challenge: a trie for autocomplete

A trie (prefix tree) stores strings character by character: each node has up to 26 children, one per letter, and a flag marking where a word ends. Every word sharing a prefix shares that path, so "how many words start with de_?" takes O(length of the prefix), no matter how many words there are. Search boxes, spell checkers and routers use tries.

Your turn: write class Trie for lowercase words:

Inserting the same word twice counts it once.

Previous: A binary heap by hand