3 votes 3 votes In a string of length $n$, how many of the following are there? Prefixes. Suffixes. Proper prefixes. Substrings. Subsequences. Compiler Design ullman compiler-design strings descriptive + – admin asked Aug 5, 2019 edited Aug 5, 2019 by Lakshman Bhaiya admin 1.8k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes $n + 1 (n$ prefixes for $n$ characters, plus the empty string$)$ $n + 1 ($similar to $(a))$ $n - 1 (n$ prefixes for $n$ characters, minus the string itself$)$ $n [1$ character substring$] + (n - 1) [2$ character substring$] + \dots + 1 = \dfrac{n (n + 1)}{2}.$ Add $1$ to include the empty substring. $\displaystyle{}\sum_{i=0}^{n} {^{n}C_{i}} = 2^{n}$, if you include the empty subsequence. pritishc answered Nov 8, 2019 edited Nov 8, 2019 by Lakshman Bhaiya pritishc comment Share Follow See all 0 reply Please log in or register to add a comment.