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

  1. A.O(n)
  2. B.O(L log n)
  3. C.O(n · L)
  4. 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 →