Phase 1: The HashSet seems fine — scan every word for a prefix.

The HashSet Seems Fine

You have a HashSet of 10,000 words. search('apple') takes O(1). Beautiful. Clean. You feel smart.

Now someone asks: “Find all words starting with 'app'.” You look at your HashSet. Your HashSet looks back at you. “I don't DO prefixes,” it says. And it's right. A hash doesn't know that apple and application start with the same letters. To the hash, they're two unrelated bit patterns that happen to look similar. Checking every word for a prefix match means scanning all 10,000 — every keystroke. Is there a way to ORGANIZE words so the same question takes constant effort regardless of how many words you have?

If this list had 10,000 words, how many taps would you need to find every word that starts with 'app'?