🎙 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 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?

  1. A.Listing all words that start with "pre"
  2. B.Counting words with a given prefix
  3. C.Checking whether an exact word is in the dictionary
  4. 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 →