🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Binary search the whole word list
  2. B.Hash the prefix
  3. C.Run a DFS from that node and collect every word ending below it
  4. 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 →