← All topics
Quiz: Tries (Prefix Trees): questions with answers
15 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. What does the end-of-word flag in a trie node tell you?
- Q2. What does this print? (code)
- Q3. Words cat, car and cart are stored. What does search("ca") return?
- Q4. What is the time to insert a word of length L into a trie that already holds n words?
- Q5. Each node keeps a count of words passing through it. How do you answer "how many words start with p"?
- Q6. What does this print? (code)
- Q7. Why might you choose a 26-slot array per node instead of a hash map?
- Q8. For which task is a plain hash set as good as a trie?
- Q9. In "word search II" (find many dictionary words in a letter grid), why does a trie help?
- Q10. Ten words share the prefix "inter". How many times are the letters i-n-t-e-r stored in the trie?
- Q11. What does this print? (code)
- Q12. How does startsWith(prefix) differ from search(word) in a trie?
- Q13. What does this print? (code)
- Q14. Autocomplete in a trie: after walking down to the node for the typed prefix, how do you list the suggestions?
- Q15. What is the main memory drawback of a trie with a 26-slot array in every node?