← Quiz: Tries (Prefix Trees): all 15 questions
Quiz: Tries (Prefix Trees) · Question 14 of 15
Autocomplete in a trie: after walking down to the node for the typed prefix, how do you list the suggestions?
Autocomplete in a trie: after walking down to the node for the typed prefix, how do you list the suggestions?
- A.Binary search the whole word list
- B.Hash the prefix
- C.Run a DFS from that node and collect every word ending below it
- D.Go back up to the root
Answer & explanation
Correct answer: Run a DFS from that node and collect every word ending below it
Every word below the prefix node starts with that prefix, so only that subtree needs to be explored.
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 →