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

Why might you choose a 26-slot array per node instead of a hash map?

Why might you choose a 26-slot array per node instead of a hash map?

  1. A.It uses less memory in every case
  2. B.It allows any Unicode character
  3. C.Child lookup is a direct index (c - 'a'), which is fast, when the input is only lowercase letters
  4. D.Hash maps cannot store trie nodes
Answer & explanation

Correct answer: Child lookup is a direct index (c - 'a'), which is fast, when the input is only lowercase letters

Arrays are fast but waste space on empty slots; maps are flexible but slower per step.

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 →