← Quiz: Tries (Prefix Trees): all 15 questions
Quiz: Tries (Prefix Trees) · Question 4 of 15
What is the time to insert a word of length L into a trie that already holds n words?
What is the time to insert a word of length L into a trie that already holds n words?
- A.O(n)
- B.O(L log n)
- C.O(n · L)
- D.O(L)
Answer & explanation
Correct answer: O(L)
We follow or create one node per letter; the number of stored words does not matter.
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 →