Data Structures & AlgorithmsModerateProduct-company placement

All suffixes of the string 'mississ' are inserted into a character trie (a suffix trie). How many nodes does it have, including the root?

  1. A. 29
  2. B. 21
  3. C. 22
  4. D. 23

Correct answer: C. 22

Every node of a suffix trie spells a distinct substring, so nodes = (number of distinct non-empty substrings) + 1 = 21 + 1. n(n+1)/2 = 28 counts repeated substrings more than once.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic