Question bank › Trie
Dsa Trie Hard

Auto-complete Suggestions

You are tasked with implementing an auto-complete system using a trie data structure. Your program should read a list of words and then support prefix searches to find all words that start with a given prefix. The output should be sorted alphabetically. Input Format: - The first line contains an integer n, the number of words in the list (1 <= n <= 10000). - The next n lines contain one word per line (1 <= length of each word <= 100). - The next line contains an integer m, the number of prefix searches (1 <= m <= 1000). - The next m lines contain one prefix per line (1 <= length of each prefix <= 100). Output Format: - For each prefix search, output the words that start with that prefix, sorted alphabetically, one word per line. If no words match, output "No suggestions". Example: Input: 5 apple appetite bat ball banana 3 app ba cat Output: apple appetite ball bat No suggestions

Key concepts

triesearchautocomplete

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.