Data Structures & AlgorithmsModerateProduct-company MCQ pattern

What is the time to search for a word of length L in a trie that holds n words?

  1. A. O(L log n)
  2. B. O(L)
  3. C. O(log n)
  4. D. O(n)

Correct answer: B. O(L)

The search follows one child pointer per character, so the cost depends only on the word length, not on how many words are stored. That is the main advantage of a trie over a BST of strings (O(L log n)).

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic