← 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?
- A.It uses less memory in every case
- B.It allows any Unicode character
- C.Child lookup is a direct index (c - 'a'), which is fast, when the input is only lowercase letters
- 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 →