Prefix tree (trie)

Insert cat, cats and car. Their first letters share a path. Test ca as a whole word, then as a prefix.

Read one symbol at a time. Follow the child for that symbol from the current node.

A whole word needs an end mark. A prefix needs a path that starts at least one stored word.

Each symbol needs one child lookup. With hashed children the average time is O(L) for a word of length L. Each new prefix uses one node.