Data Structures & AlgorithmsHardGATE CS · Product-company placement

The words trie, tried, trip, try, tree are inserted into an empty trie (one node per character, shared prefixes share nodes, plus a root). How many nodes does the trie have (including the root), and how many nodes have two or more children?

  1. A. 21 nodes, 2 branching
  2. B. 9 nodes, 2 branching
  3. C. 10 nodes, 3 branching
  4. D. 10 nodes, 2 branching

Correct answer: D. 10 nodes, 2 branching

Nodes = distinct non-empty prefixes + root = 9 + 1 = 10, not the total letter count 20. A node branches when two different next letters follow its prefix; there are 2 such nodes.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic