Data Structures & AlgorithmsModerateGATE CS · Product-company placement

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

  1. A. 16
  2. B. 12
  3. C. 13
  4. D. 14

Correct answer: C. 13

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic