16
A search backend needs to return prefix matches quickly. What structure would you use?
Tap to write answer
0 words | 0 charsPress Enter ↵ to reveal
Your Attempt
0 wordsRefined Model Answer
ReferenceI would think about a trie first, because prefix search is exactly what tries are good at. If the dataset is very large, I would also consider a compressed trie or another compact prefix index. The reason I choose a trie is that it gives fast lookup for prefix-based queries and keeps the search path simple. I would also discuss ranking metadata if the results need to be ordered by popularity or relevance. The trade-off is memory usage, since naive tries can become expensive at scale.