Prefix Search and Autocomplete
Walk the prefix, then enumerate every terminal below it with a DFS.
Cost
- Best
- O(L)
- Average
- O(L + results)
- Worst
- O(L + subtree)
- Space
- O(depth)
Before this
Taught by the same lesson
Trie covers these too, in the same run.