← Quiz: Tries (Prefix Trees): all 15 questions
Quiz: Tries (Prefix Trees) · Question 8 of 15
For which task is a plain hash set as good as a trie?
For which task is a plain hash set as good as a trie?
- A.Listing all words that start with "pre"
- B.Counting words with a given prefix
- C.Checking whether an exact word is in the dictionary
- D.Autocomplete suggestions in sorted order
Answer & explanation
Correct answer: Checking whether an exact word is in the dictionary
Exact lookups are O(L) in a hash set too; only prefix questions need the trie.
Can you get the rest right without peeking?
Take the timed Quiz: Tries (Prefix Trees) quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →