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?
- A. 29
- B. 21
- C. 22
- 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.
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
- 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…
- What is the edit distance (insert, delete, substitute; each cost 1) between SUBSEQUENT and PLATFORM?
- Dijkstra's algorithm runs from A on the directed graph A→B (4), A→F (8), B→C (1), B→D (10), C→A (3), C→D (8), C→E (6), C→F (6), E→B (1)…
- In the DAG with edges A→E, A→G, B→E, C→A, C→B, C→E, C→F, C→G, D→F, E→F, G→F, how many distinct directed paths are there from C to F, and…
- For the string PROPERTY, what are the lengths of the longest palindromic SUBSTRING and the longest palindromic SUBSEQUENCE?