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?
- A. 16
- B. 12
- C. 13
- 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.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Six sorted files have 27, 35, 38, 45, 52, 54 records. Merging two files of sizes a and b costs a + b. What is the minimum total cost to…
- What is the minimum number of edges that must be deleted from the undirected graph with edges A–B, B–C, B–E, B–F, C–D, C–E, C–F, D–F, E–F…
- What does f(3) print? c void f(int n) { if (n <= 0) return; printf("%d", n); f(n - 2); printf("%d", n); f(n - 1); }
- All suffixes of the string 'mississ' are inserted into a character trie (a suffix trie). How many nodes does it have, including the root?
- Keys 14, 86, 32, 49, 38, 76, 17, 91, 35, 81, 16 are inserted in that order into an empty BST. Then 32 is deleted and after that 86 is…
- The weighted undirected graph A–B (2), A–E (1), B–C (6), B–D (1), B–E (2), C–D (6), D–E (3) has repeated weights. How many different…