🎙 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 9 of 15

In "word search II" (find many dictionary words in a letter grid), why does a trie help?

In "word search II" (find many dictionary words in a letter grid), why does a trie help?

  1. A.The DFS can stop as soon as the current path is not a prefix of any word
  2. B.It sorts the grid
  3. C.It removes the need for DFS
  4. D.It makes every word the same length
Answer & explanation

Correct answer: The DFS can stop as soon as the current path is not a prefix of any word

Without a trie you would search for each word separately; with it, one DFS checks all words and prunes dead paths.

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 →