Build a prefix tree from scratch — insert words character by character, then search and check prefixes by walking the tree.